如何使用Twitter Bootstrap制作带模糊背景的模态对话框?

问题描述 投票:23回答:4

Bootstrap在显示模态对话框时使用停电。我如何在整个背景上模糊效果?

twitter-bootstrap bootstrap-modal blur
4个回答
41
投票

您需要先更改文档的结构。看起来应该是这样的

<body>
   <div class="supreme-container">all your content goes here except for the modal</div>
   <div id="myModal" class="modal fade">This is your modal.</div>
</body>

然后在css

body.modal-open .supreme-container{
    -webkit-filter: blur(1px);
    -moz-filter: blur(1px);
    -o-filter: blur(1px);
    -ms-filter: blur(1px);
    filter: blur(1px);
}

22
投票

如果您使用的是bootstrap,那么您的内容已经存在于某种容器中。所以这对我有用而无需改变HTML或任何其他JS:

.modal-open .container-fluid, .modal-open  .container {
    -webkit-filter: blur(5px) grayscale(90%);
}

7
投票

我认为实现这一目标的最简单方法是在模态打开时使用jQuery将blur类应用于背景元素。模态关闭时删除blur ...

.blur {
    box-shadow: 0px 0px 20px 20px rgba(255,255,255,1);
    text-shadow: 0px 0px 10px rgba(51, 51, 51, 0.9);
    transform: scale(0.9);
    opacity: 0.6;
}

http://bootply.com/74705


0
投票

对我来说,以下解决方案工作正常

.modal-open .container-fluid, .modal-open  .container {
  -webkit-filter: blur(1px);
  -moz-filter: blur(1px);
  -o-filter: blur(1px);
    -ms-filter: blur(1px);
    filter: blur(1px);
}
© www.soinside.com 2019 - 2024. All rights reserved.