(uniapp)開發模態框時,蒙版層樣式問題


問題: 在手寫模態框時,給蒙版層設置了透明度,但給其內部的模態框添加不透明背景色時發現雖然有背景色但模態框透明顯示
template:

/*憑空想象一個彈出框*/
<view class="rej_mask" catchtouchmove= 'true' v-if="isShowResMask">		
	<veiw class="rej_showToast">
	    <view class="rej_head">提示</view>
	    <view class="rej_body">
		<view>為什么</view>
	    </view>
	    <view class="rej_foot" @tap="closeMask">為什么呢</view>					 
      </veiw>
</view>			

css:

 // 拒絕后的彈出框
			 .rej_mask{
				 position:fixed;
				 left: 0;
				 top: 0;
				 right: 0;
				 width: 100%;
				 height: 100%;
				 z-index: 999;
				 // background: #000000;
				 background: rgba(0,0,0,0.7);
				 // opacity: .7;
			 }
			 .rej_showToast{
				 position: absolute;
				 width: 77%;
				 height: 372rpx;
				 background: rgba(255,255,255,1) ;
				 border-radius: 12rpx;
				 left: 50%;
				 top: 50%;
				 transform: translate(-50%,-50%);
			 }
			 .rej_head{
				 color: #333;
				 font-size: 32rpx;
				 font-weight: bold;
				 width: 100%;
				 height: 90rpx;
				 display: flex;
				 align-items: center;
				 justify-content: center;
				 margin-bottom: -20rpx;
				 margin-top: 18rpx;
			 }
			 .rej_body{
				 width: 100%;
				 height: 176rpx;
				 border-bottom: 4rpx solid #f4f4f4; 
				 display: flex;
				 align-items: center;
				 justify-content: center;
			 } 
			 .rej_body>view{
				 	width:78%;
					color: #999999;
					font-size: 32rpx;
					text-align: center;
			 }
			 .rej_foot{
				 height: 96rpx;
				 display: flex;
				 align-items: center;
				 justify-content: center;
				 color: #E02020;
			 }

原因在於我在給mask蒙版層添加不透明度時用的是opacity而不是rbba導致的,opcity的透明是可以被其后代元素繼承的,也就是說在給某個元素添加了opacity屬性時,它內部的元素全都繼承了這個透明的屬性值,所以會導致之前那種狀況
而rgba則不會被后代元素繼承。

以上。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM