有一个固定的高度,比如说1000。如果屏幕高度小于1000,则需要从此高度从顶部和底部移除150个像素。如何才能在纯js上做到这一点?
发布于 2022-01-12 09:49:15
为此,可以使用css媒体查询。
例如,
让我们假设您的代码是
css
.container{
margin-top:150px;
height:1000px
margin-bottom:150px;
}
@media (max-height: 1000px) {
.container{
margin-top:0px;
height:1000px;
margin-bottom:0px;
}
}https://stackoverflow.com/questions/70679200
复制相似问题