小程序自定义弹出层,无法固定图片位置
.isRuleShow{ display : block ; } .isRuleHide{ display : none ; } .ruleZhezhao{ height : 100% ; width : 100% ; position : fixed ; background-color :rgba( 0 , 0 , 0 , . 5 ); z-index : 2 ; top : 0 ; left : 0 ; } .ruleZhezhaoContent{ position : fixed ; width : 800 rpx; height : 1000 rpx; } .ruleZhezhaoimage{ width : 100% ; height : 100% ; } .ruleHide{ height : 60 rpx !important ; width : 60 rpx !important ; position : absolute ; top : -20 rpx; right : -20 rpx; } |
< view class = "ruleZhezhao {{isRuleTrue?'isRuleShow':'isRuleHide'}}" > < view class = 'ruleZhezhaoContent' > < image class = 'ruleZhezhaoimage' src = 'https://www.xxxxx/upload/3369f6d59bf2463fa9b4665fcd9b4d64_0429.png' ></ image > < image src = '' class = 'ruleHide' bindtap = 'hideRule' ></ image > </ view > </ view > |
如上图,怎么改css才能让图片固定在中间,并且可以增加宽度和高度。现在一增加高度或宽度就变形。margin:0 auto;也不好使
1 回复
.ruleZhezhao{
height: 100%;
width: 100%;
position: fixed;
background-color:rgba(0, 0, 0, .5);
z-index: 2;
top: 0;
left: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.ruleZhezhaoContent{
}
.ruleZhezhaoimage{
width: 800rpx;
}
<image class=“ruleZhezhaoimage” src=“https://www.xxxxx/upload/3369f6d59bf2463fa9b4665fcd9b4d64_0429.png” mode="widthFix"></image>