最近发现了个用绝对布局写自适应屏幕的写法,让我觉得,之前小程序傻傻读屏幕高再给背景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的距离来决定,超级方便好吗