html - 将页脚保持在底部(页脚不必随滚动而移动)
问题描述
我试图给我的页面额外的高度:
html {
height: 1000px;
}
这可以满足我的要求,但页脚有问题。我希望它在底部,但我不一定希望它随着滚动而移动。意思是,用户必须向下滚动才能看到页脚。
这就是我所拥有的:
html:
<footer class="footer">
<p>...</p>
</footer>
CSS:
footer {
position: fixed;
background-color: #00cca3;
bottom: 0;
height: 80px;
padding-bottom: 20px;
width: 100%;
}
当我更改position
为relative
页脚时,它位于屏幕中间,因为它相对于其他元素定位。不好。
如何在屏幕底部实现页脚而不让它与滚动一起移动?
解决方案
您需要使用position:fixed
并将顶部和右侧设置为正确的位置。无论如何它都不会移动。
推荐阅读
- python - AWS 访问的临时密钥
- c++ - 动态内存分配错误
- ios - UIView 类中的 CollectionView IBOutlet 返回 nil - 只是有时?
- android - 在 EXPO 中再次构建 singed apk 的麻烦
- python - 使用 Python (selenium) 的自动 9GAG 评论被删除了吗?
- r - 关于 raster 包中的 mask() 函数的困惑
- eclipse - 在后台运行 git bash/作为守护进程
- google-maps-api-3 - 谷歌表importxml公式错误
- sql - 为基于 SQL 的报告显示的字符数
- java - 为什么 JProgressBar 一旦添加到 JPanel 就不应更改?