templateUrl: htmls[$scope.chooseIndex], //指向上面创建的视图
controller: ctrls[$scope.chooseIndex], // 初始化模态范围
size: 'lg', //大小配置,貌似有modal-lg、modal-md和modal-sm三种,默认是modal-md的
resolve: {
item: function() {
return
},
title: function() {
return $scope.titles[$scope.chooseIndex]
},
opIndex: function() {
return 2
}
}
})
<div class="page show-modal"><div class="container">主要内容</div>
<div class="modal">浮层</div>
</div>
假设有这样的HTML结构,那么让 .modal 绝对定位在 .container 上面,.container 设置 blur 即可。
.modal {display: none
position: fixed
left: 0
top: 0
right: 0
bottom: 0
background: rgba(255,255,255,.8)
}
.show-modal .modal {
display: block
}
.show-modal .container {
-webkit-filter: blur(4px)
}
演示:http://jsbin.com/nesewayosa/1/
用CSS和JS改变z-index的属性值就可以实现模态框[html] view plain copy
<html>
<head>
<title>modal box</title>
<style type="text/css">
*{
margin:0px
padding:0px
}
</style>
</head>
<body>
<!--先在CSS里面把zindex的值设为负值让其在背景图片后面-->
<div style="background:url(http://pic.90sjimg.com/back_pic/00/04/27/49/5b1eee8bdba7b9aefc62fccafe72737c.jpg)width:100%height:800pxz-index:1">
<button id="modal-box">弹框</button>
<div id="modal-show" style="position:fixedz-index:-9999width:100%height:100%background-color:rgba(236, 214, 214, 0.2)">
</div>
<div id="modal-show2" style="position:fixedz-index:-9999width:30%height:30%margin:200px autoborder:1px solid red">
欢迎你登录
</div>
</div>
<script type="text/javascript">
document.getElementById("modal-box").onclick=function()//点击按钮改变zIndex的值为1让模态框在背景图的前面
{
document.getElementById("modal-show").style.zIndex = "1"
document.getElementById("modal-show2").style.zIndex = "1"
}
document.getElementById("modal-show").onclick=function()//点击模态框的透明背景时,模态框的zIndex值变为-9999,会隐藏在
{<span style="white-space:pre"></span>背景图片的后面,点击模态框本身是不会消失的<span style="white-space:pre">
</span>
this.style.zIndex = "-9999"
document.getElementById("modal-show2").style.zIndex = "-9999"
}
</script>
</body>
</html>