我试图将一个页脚放在html页面的底部。我一直无法在网上找到像样的教程,主要是因为我的内容虽然简单,但不是标准的(我想)。

我有以下html代码(只是一个测试页面,而不是真实的页面):

<html>

<head>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<div id = "container">


<div id = "header">
This is the header
</div>

<div id = "body">


<div class="IRL">
<div class="box"><a href= ""><img src="" width="100" height="100"></a></div>
<div class="box"><a href= ""><img src="" width="100" height="100"></a></div>
<div class="box"><a href= ""><img src="" width="100" height="100"></a></div>
<div class="box"><a href= ""><img src="" width="100" height="100"></a></div>
<div class="box"><a href= ""><img src="" width="100" height="100"></a></div>
</div>



<div id = "footer">
Testing footer
</div>

</div>
</div>
</html>


这样,“ style.css”的相关内容为:

html,

body    {
margin: 0;
padding: 0;
height: 100%;
}


#container  {
min-height:100%;
position:relative;
}

#container {
height:100%;
}

#body {
padding:10px;
padding-bottom:50px;   /* Height of the footer */
}

#footer {
position:absolute;
bottom:0;
width:100%;
height:50px;   /* Height of the footer */ //This is from a tutorial
}

.IRL {

position: absolute; top:50px; left:10px;
}


.IRL li{

margin:0px 150px 0px 0px;
list-style-type:none;

}



.box    {
margin-top: 10px;
padding: 5px 5px 5px 5px;
border: 2px solid #000000;
width:100px;
height: 100px;
color:#000000;
}


问题是页脚即使在我到达底部时(经过一些修补)也切穿了盒子。基本上没有人知道如何在包装箱之后留出空隙吗?我以为填充底部应该这样做?

我希望我已经清楚了

提前谢谢了。干杯。

最佳答案

删除所有绝对位置并添加:

.IRL {
  margin-bottom: 50px;
}


Demo

或者,调整各个元素的绝对定位topbottom值。

10-07 14:36
查看更多