【发布时间】:2021-01-21 21:17:01
【问题描述】:
我想在页面底部放一个页脚,数据量很大,但页脚应该在最顶层的内容之上:
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes">
<style type="text/css">
body{
height:2000px;
position: absolute;
width:100%;
height:100%;
}
.main{
height: 800px;
width:20%;
overflow: scroll;
background-color:red;
}
.bottom{
position: fixed;
bottom: 0px;
background-color:green;
}
</style>
</head>
<body>
<div class="main">main content
<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3
</div>
<div class="bottom">bottom</div>
</body></html>
现在我的问题是,如果我滚动页面,底部会保持在它生成的位置。
我尝试了position:fixed,这在桌面 Firefox 上很好,但在移动 Firefox 上不行:https://spacetrace.org/test.html
如果你用两根手指调整屏幕大小,底部会移位。
如何在 Firefox 移动版上也仅使用 CSS 将其保持在底部?
【问题讨论】:
-
嘿 rubo,你想把它贴在你的主 div 的底部还是你身体的底部??
-
可见屏幕底部
-
它应该在任何屏幕尺寸下漂浮在它下面的任何东西上
-
这不起作用。在向下滚动之前,绿色底部不可见。它应该一直可见