通过使用属性 position:absolute;我必须提到所有层的正确大小(在我的例子中是 3 层“#header”、“#mybody”、“#footer”),在我的网站中,#mybody 的高度是动态的。所以,我需要#footer的位置应该是相对的,但是使用相对我无法设置:100%;即使我设置 width:100% 我也没有使用相对完成 100%。但是,我使用 absolute 得到 100%,但由于上述原因我不能使用 absolute。我也不想修复页脚。如何在不使用绝对或固定位置的情况下将页脚的宽度设置为 100%?将 width:100% 与 absolute 或 fixed 以外的选项一起使用不会对我产生 100% 的完整效果。
代码:
mheadf {
position:relative;
width:100%;
height:35px;
border:thin solid black;
正文{
position:relative;
width:800px;
height:500px;
border:thin solid black;
mfootf {
position: relative;
width:100%;
height:115px;
border:thin solid black;
} -->
最佳答案
使用 width:100%;
应该使 div 的宽度为 100%,假设您的 body/div 上没有边距或填充。删除这些,您就可以开始了。
关于css - 宽度 :100% without Position:absolute/fixed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8546599/