html - 粘性页脚不会停留下来

标签 html css

在我的页面上滚动时,我的页脚不会停留在下方。有什么建议吗?

页脚的 CSS:

.footer {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  text-align: center;
  color: #f2f2f2;
  margin: 0;
  height: 150px;
  background-color: #399D60;
}

关于如何解决这个问题有什么想法吗?

最佳答案

如果您的 html 结构如下所示:

<footer>
    <!-- Your footer content go here -->
</footer>

那么你的css应该是

footer {
 /* Your css should go here*/
 /* not .footer, use footer */
}

或者你可以给它一个类 footer 这样你就可以用 .footer 定位

<footer class="footer">
    <!-- Your footer content go here -->
</footer>

现在您可以使用 .footer 等类选择器来定位它

关于html - 粘性页脚不会停留下来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55170222/

相关文章:

html - 样式化 HTML 元素的正确方法

php - 从 MySQL 结果生成的 HTML 表,以使用 PHP 的形式进行处理

javascript - 使用 Javascript/Windows 批处理文件混合将非 ASCII 字符编码为 HTML

c# - 如何在 css 中突出显示 "onmouseover"?

html - 根据单选按钮选择显示、隐藏图像

javascript - 使用 CSS 或其他非 JS 方法模仿 "onselectstart=return false"?

html - 我不能在输入标签之间放置空格

html - CSS: "inline-block"元素的意外垂直位置

javascript - 没有滚动条的 CSS 可拖动导航

javascript - 从javascript链接到url?