use*_*761 7 css twitter-bootstrap bootstrap-modal
我在我的项目中使用了bootstrap的模式弹出窗口,并希望得到以下内容:
She*_*ary 13
1)当打开模型弹出窗口并单击后台弹出窗口时,不应该关闭.
data-keyboard="false" data-backdrop="static"在模态定义中包含数据属性:
<div class="modal fade" id="myModal" role="dialog" data-keyboard="false" data-backdrop="static">
// Modal HTML Markup
</div>
Run Code Online (Sandbox Code Playgroud)
2)当打开模型弹出背景时不应模糊.意思是打开模型弹出背景不应该影响任何方式.
将.modal-backdrop属性值设置为display:none;
.modal-backdrop {
display:none;
}
Run Code Online (Sandbox Code Playgroud)
3)打开模型弹出后,用户也可以在弹出窗口不应该关闭的后台工作.
添加值 .modal-open .modal
.modal-open .modal {
width: 300px;
margin: 0 auto;
}
Run Code Online (Sandbox Code Playgroud)
SideNote:您可能需要根据媒体查询的屏幕大小调整模态的宽度.
免责声明:这个答案只是为了演示如何实现所有3个目标如果你有一个以上的bootstrap模态,上面的更改将影响所有模态,强烈建议使用自定义选择器.
.modal-backdrop {
display: none !important;
}
.modal-open .modal {
width: 300px;
margin: 0 auto;
}Run Code Online (Sandbox Code Playgroud)
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#myModal">Open Modal</button>
<br> This is a text and can be selected for copying
<br> This is a text and can be selected for copying
<br> This is a text and can be selected for copying
<br> This is a text and can be selected for copying
<br>
<div id="myModal" class="modal fade" role="dialog" data-backdrop="static">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20263 次 |
| 最近记录: |