2012-01-25 62 views
3

我有一個div是包裹在幾個其他div都是100%。我有這樣的方式,因爲我有一個外部div與一個輕微的邊框圖像,我想包裹整個頁面。爲什麼我不能得到這個div去100%高度

HTML:

<body> 
<div class="container" > 
    <div style="padding-top:15px; height:100%;"> 
     <div class="wrapper"> 
      <div class="contentContainer"> 
      test 
      </div> 
     </div> 
    </div> 
</div> 
</body> 

CSS:

*{margin:0; padding:0;} 
body { margin: 0 auto; color: #333333; } 
html, body { color: #000000; margin:0; padding:0; height:100%; } 

.wrapper {width:940px; margin-left:20px; margin-right:20px; background:#fff; overflow:hidden; margin:0 auto; height:100%;} 

.container {min-height:100%; height: auto !important; height:100%; margin: 0 auto -30px; width:980px; background:URL(images/bg_sides.jpg) repeat-y #f4f4f4;} 

.contentContainer {width:920px; margin:0 auto; height:100%; } 

小提琴:http://jsfiddle.net/hc3Xu/2/

回答

3

在.container中的height: auto !important規則是罪魁禍首。

+0

謝謝。這樣可行。我忘了我的頁腳必須留在底部。至少我可以重新安排我現在知道的東西。 – Sackling

+1

@Sackling,雖然你可以自由接受任何你想要的答案,平心而論,welldan97首先發布它,確實值得選中。 – Sparky

+0

謝謝@ Sparky672。另外我在我的答案中有一個演示鏈接。 – welldan97

0

.container具有height: auto !importantheight: 100%!important規則正在重寫。刪除它,你很好。