最近发现了个用绝对布局写自适应屏幕的写法,让我觉得,之前小程序傻傻读屏幕高再给背景view赋值min-height的写法简直太傻了
毕竟能用css解决的问题最好就不要js
.shi{
position: absolute;
top: 0px;
bottom: 0;
left: 0;
width: 20%;
background-color: black;
}
效果

可以通过top给上面留白
.shi{
position: absolute;
top: 150px;
bottom: 0;
left: 0;
width: 20%;
background-color: black;
}

块的高度由top和bottom的距离来决定,超级方便好吗
本文介绍了一种使用绝对定位实现自适应屏幕布局的方法,通过调整top和bottom属性,可以轻松控制元素高度,无需借助JavaScript,简化了小程序背景视图高度设置流程。
1万+

被折叠的 条评论
为什么被折叠?



