第4个小程序之旅的第一个问题:小程序页面设置页面高度100%
放代码:
<view class='login-container'>
<view class='form-container'>
</view>
</view>
wxss
.login-container{
position: fixed;
height: 100%;
width: 100%;
display:flex;
flex-direction:column;
align-items:center;
justify-content: center;
}
.form-container{
position: absolute;
bottom: 30rpx;
height: 70%;
width: 90%;
border-radius: 25rpx;
background: red;
}
关键代码是父元素设置position: fixed;height: 100%;width: 100%;
注意了里面的子元素不要再使用fixed,使用absolute基于父元素定位