【发布时间】:2013-09-08 01:37:05
【问题描述】:
我对 doctype 声明有一个奇怪的问题。我希望我的页脚粘在页面底部。当我声明文档类型时,它没有发生。当我删除文档类型时,页脚粘在底部。
代码 -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="styles.css"/>
</head>
<body>
<div id="wrapper">
<div id="header">
</div>
<div id="content">
</div>
<div id="footer">
</div>
</div>
</body>
</html>
CSS -
#wrapper{
border: 1px solid black;
position: relative;
min-height:100%;
}
#header{
height: 100px;
background: green;
}
#content{
height: 100px;
background: red;
width: 400px;
margin:0 auto;
}
#footer{
height: 50px;
background: blue;
position: absolute;
bottom: 0;
left:0;
right:0;
}
知道如何解决这个问题吗?
【问题讨论】:
-
如果您使用 XHTML,请为您的 html 标签使用 xml:lang 和 xmlns 属性。也用 /> 关闭元标记,也用