html - 如何在 HTML 和 CSS 中使用 html 对象编写粘性页脚?

标签 html css web sticky-footer

我正在为我正在设计的两个网站使用 Less Framework 4。在这两种设计中,我都想在文档的顶部和底部应用 5 像素的边框。

问题:由于应用于 body 的样式,我将 border-bottom 和 border-top 应用于 html 对象,所以底部边框永远不会粘在页面底部,就像在通常的粘性页脚情况下一样。

两种情况的截图如下:

My Redesign

Belgian client

这是我用于 html 和 body 的(LESS)CSS:pastie.org/private/us5x1vhjnwzq6zsiycnu2g

html {
    border-top: solid @black 10px;
    border-bottom: solid @black 10px;
    background: url('img/bg.png') repeat;
}

body {
    width: @8col;
    margin: 0px auto;
    padding: 100px 48px 84px;
    background: @white;
    color: rgb(60,60,60);
    -webkit-text-size-adjust: 100%; /* Stops Mobile Safari from auto-adjusting font-sizes */
    font: 13px/20px 'OftenRegular';
    -webkit-tap-highlight-color: @green;
}

我已经尝试对 bodyhtml 对象使用 height: 100%,但实际情况如下:http://prikonline.be/prikactie/

如何将边框固定在页面底部?

最佳答案

您可以改为使用这样的页脚包装器。

.footer {
  position: absolute;
  bottom: 0;
  border-bottom: solid @black 10px;
  width: 100%;
}

然后将其插入到 </body> 之前或某事

<div class="footer"></div>

关于html - 如何在 HTML 和 CSS 中使用 html 对象编写粘性页脚?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6242136/

相关文章:

javascript - 文本框不在 slider 的中心位置

javascript - 如何在 React 中禁用挂载时的初始悬停过渡?

javascript - 获取在 Node/Express 中传递不同数据的相同 URL 的方法

javascript - 干净的 url 在没有标签的前端管理

forms - 将自定义 html 表单数据发布到 zoho crm

javascript - 将变量分配给 HTML 选择器、类

html - 导入字体 Internet Explorer

java - 使用 Jsoup 从输入中获取名称标签

html - 部分 header 仅在 IE9 中被截断

HTML/CSS - 将 td 放在 li 中会删除 li 的左边距吗?