我在底部页脚有一个 DIV,我想始终保持在屏幕的顶部和底部,但仅在顶部并在像素上定位时固定在底部(例如:从上到下 500px)。
如果<500px 是名义 DIV,则底部> 500px 是固定的。
我使用css,但这总是底部。
body {
margin-bottom:90px;
}
#footer {
bottom: 0px;
position:fixed;
margin-top: 10px;
width: 100%;
}
您需要为此使用媒体查询:
.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; }
}