最近發現了個用絕對佈局寫自適應屏幕的寫法,讓我覺得,之前小程序傻傻讀屏幕高再給背景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的距離來決定,超級方便好嗎