js+html5实现半透明遮罩层弹框效果

js+html5实现半透明遮罩层弹框效果

点击按钮,出现半透明遮罩层弹框,说说自己之前发过的愁吧

1、遮罩层半透明了 弹框也跟着半透明了 就像这样 绝望吧 

js+html5实现半透明遮罩层弹框效果

是哪里错了呢?你的css是这样写的吧:

js+html5实现半透明遮罩层弹框效果

应该这样:

js+html5实现半透明遮罩层弹框效果

需要注意的是这几个参数的意思:RGB Red Green Bule 3色!及212, 0, 0 三色的值混合 .最后一个参数 0.5 是指的透明度 1表示不透明

2、半遮罩层里面的内容可以上下滑动 感觉挺好玩的 /笑哭

修改就是把半遮罩层的position设置为fixed 里面的内容就不会变啦

接下来就是代码show

<!doctype html>
<html>
 <head>
 <meta charset="UTF-8">
 <title></title>
 <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
 <style type="text/css">
 *{
 margin: 0;
 padding: 0;
 }

 .tip{
 text-align: center;
 position: absolute;
 height: 100%;
 width: 100%;
 background-color: rgba(90, 90, 90, 0.5);
 z-index: 99999;
 }
 
 .collectSucc{
 position: fixed;
 height: auto;
 width: 70%;
 background-color: #ffffff;
 margin-left: 15%;
 margin-top: 50%;
 }
 
 .collectSucc_top{
 color: #666666;
 font-size: 12px;
 }
 
 .collectSucc_top img{
 width: 60px;
 margin-top: 20px;
 }
 
 .collectSucc_buttom{
 margin-top: 20px;
 height: 40px;
 line-height: 40px;
 background-color: #2d99f5;
 color: #FFFFFF;
 font-size: 13px;
 }
 </script>
 
 </head>

 <body>
 <div class="tip">
 <!--收款成功-->
 <div class="collectSucc">
 <div class="collectSucc_top">
 <img src="../../img/tip.png" />
 <div>抢单失败,试试其他行程吧!</div>
 </div>
 <div class="collectSucc_buttom">
 我知道了
 </div>
 </div>
 </div>
 你好 我叫欧琪 啊哈哈 
 
 </body>

</html>

样式是这样的:

js+html5实现半透明遮罩层弹框效果

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。