【发布时间】:2015-01-05 10:38:14
【问题描述】:
我想知道如何将页脚宽度设置为 100%?我尝试将 .footer-container 和 .footer 宽度设置为 100% 以及绝对位置。
这是网站:
【问题讨论】:
-
您的页脚设置为其父容器的 100%。此外,您应该提供自己的代码,而不是指向您网站的链接。你希望它是浏览器窗口的 100% 吗?
我想知道如何将页脚宽度设置为 100%?我尝试将 .footer-container 和 .footer 宽度设置为 100% 以及绝对位置。
这是网站:
【问题讨论】:
如果您将div.footer-container 移到div.page 容器之外,它应该会自动覆盖页面的宽度。
之前:
<div class="page">
...
<div class="footer-container">...</div>
</div>
之后:
<div class="page">
...
</div>
<div class="footer-container">...</div>
【讨论】:
正如@Hubro 在他的回答中提到的,将div.footer-container 移到div.page container 之外是理想的。但是,如果您不想移动 div,您可以尝试对页脚使用绝对定位,如下所示
.wrapper{
position: relative;
}
.footer-container{
width: 100%;
position: absolute;
left: 0;
bottom: -27px; (height of the footer container)
}
【讨论】:
从class="page" 中删除class="footer-container" 并使其成为class="wrapper" 的直接子代
来自
到
【讨论】:
试试下面的代码 - 我希望这就是你要找的
.footer-container {
left: 0px;
width: 100%;
position: fixed;
bottom: 0px;
}
【讨论】:
您应该将 .footer-container 放在 .page 之外,然后在 .footer-container 中添加一个 div ,其类为 .page 以使页脚内的内容具有相同的宽度。
<div class="page">Your page content</div>
<div class="footer-container">
<div class="page">
Footer Content
</div>
</div>
【讨论】: