微信小程序首页底部背景设置position: absolute 兼容多端显示

32 阅读1分钟
 <view class="index_wrap">
        <!-- 底部背景色 -->
        <view class="index-bg"></view>
        <!-- 头部显示部分;需要根据主题是变化 -->
        <view class="topHeadView">
        </view>
        <!-- 内容部分 -->
        <view class="content_wrap">
        </view>
</view>
page {
    background-color: white;
    padding-bottom: 200rpx;
}

.title {
    font-weight: 500;
    font-size: 36rpx;
    color: white;
    /* line-height: 50rpx; */
    text-align: center;
    /* padding-top: 5rpx; */
    padding-bottom: 20rpx;
}

.index_wrap {
    display: flex;
    flex-direction: column;
    position: relative;
}
.index-bg {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 720rpx;
    z-index: -1;
    background: linear-gradient(180deg, var(--themeColor) 0%, #FFFFFF 100%, #FFFFFF 100%);
}


.topHeadView {
    width: 100%;
    /* height: 670rpx; */
    display: flex;
    flex-direction: column;
    /* justify-content: space-between; */
    /* background: linear-gradient(180deg, var(--themeColor) 0%, #FFFFFF 100%, #FFFFFF 100%); */
}

.topHeadWrap {
    /* display: flex;
    flex-direction: column; */

    display: flex;
    flex-direction: row;
    padding-top: 20rpx;
    position: relative;
    height: 112rpx;
}