<view class="father"> <view class="son"> </view> </view>
.father{ width: 600rpx; height: 600rpx; background-color: orangered; position: relative; } .son{ width: 300rpx; height: 200rpx; background-color: lawngreen; position: absolute; top: 50%; left: 50%; margin-top: -100rpx; margin-left: -150rpx; }
原文:https://www.cnblogs.com/P201721440036/p/11828624.html