WeChat Mini Programs's page layout problem

the head and tail are fixed, and the middle content is not fixed. The effect is that when the content of the second part of the page is less, the three parts just occupy the screen. When there is more content, the second step is highly adaptive, and the third part is closely followed by the second part

. How do you judge the height in the

wxm file when you read a lot of data?

clipboard.png

index.wxml

< view class= "class_first" >
the first part of the content, the height is a fixed rpx
< / view >
< view class= "class_second" style= "height: {{second_height}} px" >
the second part of the content, less content occupies the rest of the screen to fill the entire height, when there is more content, it appears in the second part of the scroll bar

.

< / view >

< view class= "class_third" >
the third part of the content, the height is fixed rpx, follows the second part
< / view >

index.wxss

.class _ first {
background-color:-sharp666;
color:-sharpfff;
/ highly fixed 300rpx /
height: 300rpx;
}

.class _ second {
background:-sharpe5e5e5;
color:-sharp000;
}

.class _ third {
background-color: rgba (241,238,12,0.918);
color:-sharpfff;
/ highly fixed 200rpx /
height: 200rpx;
}

index.js

Page ({

)

data: {

second_height: 0

},
onLoad: function (options) {

let that = this
// 
wx.getSystemInfo({
  success: function(res) {
    console.log(res);
    // 
    console.log("height=" + res.windowHeight);
    console.log("width=" + res.windowWidth);
   
    // ,px
    that.setData({
      // second =  - firstpx300rpxpx
      second_height: res.windowHeight - res.windowWidth / 750 * 500
    })
  }
})

}

})

Oct.21,2021

has been solved. You can set the height of the second part to min-height: calc (100vh-head height-bottom height) to achieve the effect, that is,
< view class= "class_second" style= "min-height: calc (100vh-500rpx)" > self-testing is available


  1. what is the criterion for judging whether the building owner has more or less data? Whether to calculate the number of lines according to the number of words, so as to get the full length of the display, or other
  2. if the standard in 1 can be determined and the total height of the screen can be obtained, some variables can be used to control whether the class of part 2 and part 3 is displayed
  3. .
Menu