赞
踩
挺常见的功能,因首次开发微信小程序,故此做一波记录 ~
最终效果:view覆盖
//1.position
//2.z-index
//父布局
position: relative;
//子布局
position: absolute;
//view层级顺序 → 数值越高就离用户越近
z-index: 1;
position: relative;
z-index: 1;
.parent_style {
background-color: #501370;
height: 50rpx;
position: relative;
width: 100%;
z-index: 1;
}
注意
子view1
position: absolute;
z-index: 2;
.big_son_style {
color: #fff;
background-color: #73b939;
font-size: 28rpx;
height: 100%;
position: absolute;
z-index: 2;
}
子view2
position: absolute;
z-index: 3;
.small_son_style {
color: #fff;
background-color: #f00;
font-size: 28rpx;
height: 100%;
position: absolute;
z-index: 3;
}
.wxml
<view class='parent_style'>
<text class='big_son_style'>你觉得女人都是蛮不讲理的吗?</text>
<text class='small_son_style'>我觉得是...</text>
</view>
.wxss
.parent_style { background-color: #501370; height: 50rpx; position: relative; width: 100%; z-index: 1; } .big_son_style { color: #fff; background-color: #73b939; font-size: 28rpx; height: 100%; position: absolute; z-index: 2; } .small_son_style { color: #fff; background-color: #f00; font-size: 28rpx; height: 100%; position: absolute; z-index: 3; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。