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;
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM