div非弹出框半透明遮罩实现全屏幕遮盖css实现

IE浏览器下设置元素css背景为透明:

background-color: rgb(0, 0, 0);  
filter: alpha(opacity=20);  

非IE浏览器下设置元素css背景为透明:

background-color: rgba(0, 0, 0, 0.2);

兼容各类浏览器设置css背景为透明办法,即两者合并设置css:

 (ie 不支持 rgba,所以rgba不会起作用)

background-color: rgb(0, 0, 0);  
filter: alpha(opacity=20);  
background-color: rgba(0, 0, 0, 0.2);  

另:RGB与16进制色互转网站:http://11.1m86.com/

 

1.弹出框默认状态下是隐藏的,当点击弹出按钮时,显示该弹出框,如下:

<div class="modal" style="display: none;">  </div>

2.控制弹出框显示的遮罩层CSS(遮罩整个屏幕,即添加一个灰色背景遮罩层)如下:

.modal {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    overflow: hidden;
    outline: 0;
    -webkit-overflow-scrolling: touch;
    background-color: rgb(0, 0, 0);  
    filter: alpha(opacity=60);  
    background-color: rgba(0, 0, 0, 0.6); 
    z-index: 9999;
}

 

转载于:https://www.cnblogs.com/wenzheshen/p/5888786.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值