首页 > 解决方案 > 是否有一个简单的 html 代码可以在内容最少的页面底部添加页脚?(不使用 CSS)

问题描述

我希望找到某种在页脚标记中输入代码的方法(就像在我的示例中一样),以将页脚粘贴在底部而不是刚好在我的内容末尾下方。有没有办法在没有 CSS 的情况下做到这一点?抱歉,如果我的术语不正确,我几天前才开始学习 html。

<!doctype html>
<html>
    <head><title> Sample Website </title></head>
<body>I want the footer at the bottom of the page</body>

  <footer height="0">This is a footer test for a short page</footer>

</html>

标签: htmlfooter

解决方案


你可以用非常少的 CSS 来做到这一点..

footer {
  height: 100px;
  width: 100%;
  position: fixed;
  bottom: 0;
  left: 0;
}
<footer>
  This is a footer test for a short page
</footer>

或者您可以使用内联 CSS:

<footer style="height: 100px; width: 100%; position: fixed; bottom:0; left:0;">This is a footer test for a short page</footer>

推荐阅读