tml和body的高度并不一定相同,在內容少的時候,body的高度要小于html,當然這只會出現在body中的內容所占的空間高度小于瀏覽器的視口高度的時候,此時html的高度大于body的高度。網頁中的元素都是以body最為參考,所以有必要保持html和body的高度相同。
CSS Code復制內容到剪貼板
html,body{height:100%;}
第一種方法:
在body中使用兩個容器,包括網頁的頁腳和另外一部分(container)。設置container的高度為100%;頁腳部分使用 負外邊距 保持其總是在最下方。
CSS Code復制內容到剪貼板
html, body {
height:100%;
}
.fl {
float:left;
display:inline;
}
#container {
width:100%;
height:300px;
overflow:hidden;
height:100%;
border-bottom:70px #FFFFFF solid;
}
.aside {
width:30%;
}
.article {
width:70%;
}
#footer {
height:50px;
width:100%;
clear:both;
margin-top:-50px;
border-bottom:1px solid #e0e0e0;
border-top:1px solid #e0e0e0;
}
XML/HTML Code復制內容到剪貼板
<div id="container">
<div id="header">
<div>
<img src="" width= height= alt="" />
<div>
<p>fddfv</p>
新聞熱點
疑難解答