2014-02-27 74 views
0

我目前失去了如何處理我的問題。我有一個雙列布局,有一個固定的頁眉和頁腳。我希望身體中的列一直走到頁面的底部,我一直在玩100%的高度,JS等,但我似乎無法找到任何工作。我的代碼如下:使用固定頁腳獲取列到頁面底部

HTML:

<html lang="en"> 
<head> 
    <title>My Title</title> 
    <meta charset="utf-8" > 
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE" /> 
    <!--CSS Styling--> 
    <link rel="stylesheet" type="text/css" href="CSS/basic.css"> 

</head> 

<body> 
    <!-- Header--> 
    <header> 
     <div id="header-container"> 

      <!-- Hidden heading for outline --> 
      <h1>Main Title </h1> 

      <a href="index.html"><img src="Images/header-logo.jpg" alt="header-logo" width="220" height="50"/></a> 

      <nav class="clearFix"> 

       <ol> 
        <li><a href="news.html">News</a></li>  
        <li><a href="about.html">About</a></li> 
        <li><a href="services.html">Services</a></li> 
        <li><a href="tips.html">Tips</a></li> 
        <li><a href="contact.html">Contact</a></li> 
        <li><a href="disclaimer.html">Disclaimer</a></li> 
       </ol> 
      </nav> 
     </div> 
    </header> 

    <!--Main--> 
    <div id="wrapper"> 
     <main class="gridSystem clearFix"> 

      <section class="grid" id="home"> 
       <h1>Welcome to Site</h1> 

       <img class="headshot" src="Images/headshot.jpg" alt="brittany-headshot" width="300" height="300"/> 
       <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.</p> 

       <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.</p> 

       <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.</p> 
      </section> 



      <section class="grid" id="home-services"> 
       <h2>Services Offered</h2> 

       <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.</p> 

       <ul> 
        <li>Item1</li> 
        <li>Item2</li> 
        <li>Item3</li> 
        <li>Item4</li> 
        <li>Item5</li> 
       </ul> 
      </section> 

     </main> 
    </div> 
    <footer><p>Copyright | &copy; 2014 </p></footer> 

</body> 

</html> 

CSS:

*{border: none; 
margin: 0; 
padding:0;} 

body{font-family: Arial, Helvetica, sans-serif; 
background-color: #828282; 
} 

#wrapper{ 
position: relative; 
top: 65px; 
margin: 0 auto; 
width: 940px; 
background-color: #828282; 
height:100%; 
} 

/* Header*/ 
header{ 
height: 60px; 
width: 100%; 
background-color: #000000; 
margin: 0px; 
border-bottom: 5px solid #f0f0f0; 
position: fixed; 
z-index: 5; 
} 
#header-container{ 
width:940px; 
height: 50px; 
margin: 0 auto; 
} 
header img{ 
margin-left: 0px; 
margin-top: 5px; 
float:left; 
} 
header h1{ 
display: none; 
} 

/* Navigation */ 
nav{  
float:left; 
margin-top: 30px; 
margin-left: 0px; 
font-size: 18px; 
color: black; 
font-weight: 300; 
} 

nav li{ 
display: inline-block; 
width: 100px; 
padding-right: 0px; 
padding-left: 0px; 
margin: 0; 
background-color: #424242; 
margin-left: 15px; 

} 
nav li:first-child{ 
margin-left: 20px; 
} 

nav ol { 
display: inline-block; 
list-style-type: none; 
margin: 0px; 
padding: 0px; 
text-align: center; 
} 

nav a {text-decoration: none; 
margin: 0; 
} 

/*General Styling*/ 
h1{ 
font-size: 30px; 
} 

h1,h2,h3,p{ 
padding-bottom: 20px; 
} 
ul{ 
margin:0px 20px; 
} 
a:link {color:#999999;}  /* unvisited link */ 
a:visited {color: #999999;} 
a:hover {color:#FFFFFF;} /* mouse over link */ 
a:active {color:#FFFFFF;} /* selected link */ 

/*--index.html--*/ 
.grid{ 
display:block; 
margin: 0px 20px 20px 0; 
padding: 20px; 
float: left; 
} 
#home{ 
width: 580px; 
background-color: #c0c0c0; 
} 
#home-services{ 
width: 260px; 
background-color: #c0c0c0; 
margin: 0; 
} 
.headshot{ 
float: left; 
margin-right: 20px; 
margin-bottom: 20px; 
} 
/*--grid--*/ 
.gridSystem{ 
margin-right: -20px; 

} 
/* -- footer --*/ 
footer p {font-size: 10px; 
color:#f0f0f0; 
text-align: center; 
line-height: 30px; 
} 
footer {border-top: 5px solid #f0f0f0; 
height: 30px; 
width: 100%; 
background-color: #000000; 
color: #ffffff; 
position: fixed; 
bottom: 0; 
} 

/*--ClearFix--*/ 
.clearFix:after { 
clear: both; 
display: table; 
content: ""; 
overflow: hidden; 
} 

任何人都可以在這裏可能借我個忙嗎?這將不勝感激。

+0

我不清楚你實際上想要什麼。左欄已經在正確的位置,對嗎?而正確的一個必須與底部對齊而不是左對齊? – Siyah

+0

在較大的分辨率下,我需要兩列才能進入頁面的底部。左側列在大分辨率顯示器上停止一半左右。 –

回答

1

我不是100%肯定我明白你在找什麼在這裏,但我創建了一個搗鼓什麼,我想,你希望

http://jsfiddle.net/wvZqr/

我添加了一個最小高度,以你的。電網類,使兩列的高度

.grid { 
display: block; 
margin: 0px 20px 20px 0; 
padding: 20px; 
float: left; 
min-height: 620px; 
} 

這等於就是JS的方法來完成這個

您將需要包括jQue RY任何版本應該做的,然後下面

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> 
<script> 

    $(function(){ 
     var grid = $(window).height(); 
     var gridFinal = grid - 85; 
     $('.grid').css({'min-height': ((gridFinal))+'px'}); 
    }); 

</script> 

對於85我正在計算此基礎上你的頭是50像素高度和你的35頁腳給予總額的85是改變只是改變了85腳本標記到任何新的組合高度之間的頁眉和頁腳

+0

基本上我正在尋找使兩個列100%,所以無論如何,每個columm進入頁面/頁腳的底部。 –

+0

是否有一個原因,這與像素值的作品,但當我切換到100%,它不起作用? –

+0

這是一篇很不錯的文章,解釋爲什麼高度%是一個壞主意...... http://webdesign.about.com/od/csstutorials/f/set-css-height-100-percent.htm 如果您發現我的答案正確無誤,請標記爲已接受的複選標記。 – Travis