Html 更改引导模式的默认宽度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38833424/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
changing the default width of bootstrap modal
提问by John
I am trying to change the default width of the dialog but it's not working.I have tried solutions mentioned in thispost. Here is my HTML code below:
我试图改变对话框的默认宽度,但它不是working.I尝试中提到的解决方案这个职位。下面是我的 HTML 代码:
<style>
#myDialog .modal-dialog{
width:80%;
}
</style>
<div id="myDialog" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fa fa-times"></i></button>
<div class="modal-title" id="Dialog_title">Text Document</div>
</div>
<div class="modal-body">
<div id="my_doc_content"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" onclick="rg.closeDialog('myDialog');">Close</button>
</div>
</div>
</div>
</div>
采纳答案by Steff Yang
Here is a JSFiddle that may help you: Working JSFiddle
这是一个可以帮助您的JSFiddle:工作 JSFiddle
When CSS style is added on the class .modal
instead of .modal-dialog
, you can then simply change the width of the modal as you want by the following code:
当在类上添加 CSS 样式.modal
而不是 时.modal-dialog
,您可以根据需要通过以下代码简单地更改模态的宽度:
.modal{
width: 80%; /* respsonsive width */
margin-left:-40%; /* width/2) */
}
$(function() {
$("#myDialog").modal("show");
});
.modal-dialog {
width: 80%;
margin: auto;
}
.modal{
width: 80%; /* respsonsive width */
margin-left:-40%; /* width/2) */
}
<div id="myDialog" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fa fa-times"></i></button>
<div class="modal-title" id="Dialog_title">Text Document</div>
</div>
<div class="modal-body">
<div id="my_doc_content"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" onclick="rg.closeDialog('myDialog');">Close</button>
</div>
</div>
</div>
</div>
Hope this helps you!
希望这对你有帮助!
回答by M.Tanzil
Overridethe .modal-dialog
width
覆盖的.modal-dialog
宽度
.modal-dialog{
width: 80%;
margin: auto;
}
Place this piece of code in after the bootstrap.min.css
to override its default width.
将这段代码放在 之后bootstrap.min.css
以覆盖其默认宽度。
Here is working fiddle
这是工作小提琴
回答by Hitmands
I always suggest to work with non-builtfiles, working with sources you can take benefits from variables, mixinsand, when needed, add/modifysome default behaviour not explicitly exposed...
我总是建议使用非构建文件,使用可以从变量、mixin 中受益的源代码,并在需要时添加/修改一些未明确公开的默认行为......
so, going to https://github.com/twbs/bootstrap/blob/v4.0.0-alpha.3/scss/_modal.scssyou can see where sizes are defined and add/edit them as you need...
因此,转到https://github.com/twbs/bootstrap/blob/v4.0.0-alpha.3/scss/_modal.scss,您可以看到定义大小的位置并根据需要添加/编辑它们...
// example
@include media-breakpoint-up(lg) {
.modal-extralg { max-width: $modal-lg * 2; }
}
回答by Ria
Just use id:
只需使用标识:
#myDialog {
width:80%;
}