放代码:

<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基于父元素定位
第4个小程序之旅的第一个问题:小程序页面设置页面高度100%

相关文章:

  • 2022-12-23
  • 2021-12-25
  • 2022-12-23
  • 2021-05-13
  • 2021-12-18
  • 2021-12-15
  • 2022-12-23
  • 2021-12-18
猜你喜欢
  • 2021-07-27
  • 2022-01-07
  • 2021-06-08
  • 2021-07-31
  • 2022-01-07
  • 2021-12-04
相关资源
相似解决方案