css实现弹出对话框的同时出现遮罩层

2020-07-23 20:54:53
本文给大家介绍如何用css实现弹出对话框的同时出现遮罩层,有一定的参考价值,有需要的朋友可以参考一下,希望对你们有所帮助。

最近的项目有留言板弹出对话框,然后我就自己写了一个静态的,下面就直接上代码:

<p class="fade"></p><p class="succ-pop"><h2 class="title">这里是要填写的内容</h2></p>
/*灰色遮罩层*/.fade {   width: 100%;   height: 100%;   background: rgba(0, 0, 0, 0.5);   position: fixed;   left: 0;   top: 0;   z-index: 2;}/*弹出层*/.succ-pop {   width: 400px;   height: 300px;   background: #fff;   position: fixed;/*这里的定位可以根据自己喜好选择absolute或者fixed*/   left: 50%;   top: 50%;/*这里的top根据自己的需要定*/   margin-left: -200px;   margin-top: -150px;   z-index: 3;   border-radius: 5px;   box-shadow: 0 1px 3px rgba(0,0,0,.3);}.succ-pop h2.title {   text-align: center;   color: lightskyblue;}

如果你不希望有弹框的时候页面还会滚动,那就加上$('body').css('overflow-y','hidden');就可以了。

总结:以上就是本篇文的全部内容,希望能对大家的学习有所帮助。更多相关教程请访问 CSS视频教程!

相关推荐:

php公益培训视频教程

CSS在线手册

div/css图文教程