我在底部页脚有一个 DIV,我希望始终保持在屏幕的顶部和底部,但仅在顶部并在位置超过像素时固定在底部(例如:从上到下 500px)。
如果 < 500px 是正常 DIV,> 500px 则固定在底部。
我已经使用CSS,但这总是底部。
body {
margin-bottom:90px;
}
#footer {
bottom: 0px;
position:fixed;
margin-top: 10px;
width: 100%;
}
Run Code Online (Sandbox Code Playgroud)
您需要为此使用媒体查询:
CSS:
#footer {
top: 0px; /* you can delete these two lines if you want the position as it is */
position:fixed;
margin-top: 10px;
width: 100%;
}
@media screen and (min-width:500px){
#footer { bottom: 0px; }
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2606 次 |
| 最近记录: |