2013-01-10 32 views
0

我有幾個div,其中一個覆蓋另外兩個。因此,對於底部的div我用這樣的事情(CSS):如何減少頁面的底部溢出CSS/HTML

position:relative; 
top:-200px; 

但現在我有剩餘的上是空的頁面底部200個像素。我如何切斷/清除溢出? 完整的CSS代碼:

div.headertop 
{ 
    background-image:url('images/bkb.png'); 
    background-repeat:repeat; 
    width: 1000px; 
    height:200px; 
    background-color: black; 
    color:white; 
    display: block; 
    margin-left: auto; 
    margin-right: auto; 
} 
div.headerbottom 
{ 
    background-image:url('images/bkg.png'); 
    background-repeat:repeat; 
    background-position:bottom; 
    width: 1000px; 
    height:125px; 
    position:relative; 
    margin-left: auto; 
    margin-right: auto; 
} 
div.headerlogo 
{ 
    background-image:url('images/bkw.png'); 
    background-repeat:repeat; 
    width: 800px; 
    height:200px; 
    position:relative; 
    top:-200px; 
    margin-left: auto; 
    margin-right: auto; 
} 
div.content 
{ 
    background-image:url('images/bkg.png'); 
    background-repeat:repeat; 
    background-position:top; 
    width: 1000px; 
    min-height:500px; 
    position:relative; 
    top:-200px; 
    margin-left: auto; 
    margin-right: auto; 
} 
div.footer 
{ 
    background-image:url('images/bkb.png'); 
    background-repeat:repeat; 
    width: 1000px; 
    height:100px; 
    line-height:100px; 
    background-color: black; 
    position:relative; 
    top:-200px; 
    color:white; 
    display: block; 
    margin-left: auto; 
    margin-right: auto; 
    color: white; 
    text-align: center; 
} 

HTML正文代碼:

<body> 
     <div id="back"> 
      <div class="headertop"> 
       Hello! 
      </div> 
      <div class="headerbottom"> 
      </div> 
      <div class="headerlogo"> 
       <a href="index.html"><img border="0" src="images/logo.png" alt="Future Me - Home"/></a> 
      </div> 
      <div class="content"> 
       Lorem ipsum dolor sit amet, consectetur adipiscing... 
      </div> 
      <div class="footer"> 

      </div> 
     </div> 
    </body> 
+3

如果您發佈了示例工作代碼,那將會很棒。 html和css – Sowmya

+0

固定身體的高度 –

+0

@Pwn固定身體的高度會阻止頁面調整到頁面內容的正確高度,可能會太早切斷! – drmonkeyninja

回答

2

嘗試margin-top: -200px而不是使用top: -200px

1

drmonkeyninja是正確的!但只適用於margin-top.content,否則.headerlogo將不可見。此外,應用由drmonkeyninja建議修復時從.footer刪除top - (!除非這是你的課程意向)留下top不會強迫頁腳到頁面底部

我還注意到,color: white;被複制針對.footer =)