当打开Bootstrap模式(例如the GetBootstrap modal sample)时,页面的其余部分会被微妙淡出以引起对模态的注意:
Bootstrap如何实现这一目标?类.modal-open
似乎已添加到正文中,但这只会设置overflow: hidden
。还有什么是Bootstrap添加/更改导致该效果?模态在页面中的定位是否重要?
(这是一种迂回的方式,可以解释为什么我的模态不会在它打开时淡出背景。代码太复杂而无法发布,并且可能在那里&# 39;我的标记或CSS中存在缺陷。如果我知道Bootstrap如何完成不透明的背景,我可以调试它为什么不能为我工作。)
答案 0 :(得分:1)
Bootstrap添加一个div并为其添加一些类。其中黑色背景设置为.5不透明度。并添加样式以将高度设置为视口/浏览器屏幕。
<div class="modal-backdrop fade in" style="height: 984px;"></div>
如果您的模态没有淡出,请检查您是否正在使用:
display:block!important /* notice !important */
答案 1 :(得分:1)
当模态出现时,它会在modal-backdrop fade in
容器之前添加一个带有modal-dialog
类的div容器。