如何使用bootstrap将模态窗口的最大高度设置为当前浏览器窗口大小的80%。 感谢
答案 0 :(得分:0)
实现这一目标的一种方法是使用包装器。例如,您可以使用以下代码:
HTML
<div id="wrapper">
<!-- Your Code Here -->
</div>
CSS
#wrapper {
height: 80%;
}
所以,你只需将#wrapper
放在所有代码周围(当然是在正文之后),它会使你所有内容的最大高度达到80%。
答案 1 :(得分:0)
我认为这就是您要做的事情:限制对话框高度。
.modal-dialog {
position: fixed;
margin: 0;
width: 100%;
height: 80%;
padding: 0;
}
示例代码段
body {
background: #eee;
}
.modal {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
overflow: hidden;
}
.modal .modal-dialog {
position: fixed;
margin: 0;
width: 100%;
height: 80%;
padding: 0;
}
.modal-content {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
border: 2px solid #3c7dcf;
border-radius: 0;
box-shadow: none;
}
.modal-header {
position: absolute;
top: 0;
right: 0;
left: 0;
height: 50px;
padding: 10px;
background: #6598d9;
border: 0;
}
.modal-title {
font-weight: 300;
font-size: 2em;
color: #fff;
line-height: 30px;
}
.modal-body {
position: absolute;
top: 50px;
bottom: 60px;
width: 100%;
font-weight: 300;
overflow: auto;
}
.modal-footer {
position: absolute;
right: 0;
bottom: 0;
left: 0;
height: 60px;
padding: 10px;
background: #f1f3f5;
}
.btn {
height: 40px;
min-width: 100%;
border-radius: 0;
-webkit-transition: all 300ms ease-in-out;
-moz-transition: all 300ms ease-in-out;
-o-transition: all 300ms ease-in-out;
transition: all 300ms ease-in-out;
}
.btn:focus,
.btn:active,
.btn:active:focus {
box-shadow: none;
outline: none;
}
.btn-modal {
height: 50px;
width: 100%;
margin-bottom: 20px;
}
.btn-modal:hover,
.btn-modal:focus,
.btn-modal:active {
height: 75px;
color: #fff;
background: #266080;
font-size: 20px;
border-bottom: 10px solid #fff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}
.btn-primary {
font-weight: 600;
font-size: 1.6rem;
color: #fff;
text-align: center;
background: #0791DE;
border: 1px solid #266080;
border-bottom: 6px solid #266080;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}
.btn-secondary {
color: #fff;
font-weight: 300;
font-size: 1.6rem;
text-align: center;
background: #f00;
border: 1px solid #fff;
border-bottom: 3px solid #fff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}
.btn-secondary:hover,
.btn-secondary:focus,
.btn-secondary:active {
color: #f00;
font-weight: 300;
font-size: 1.6rem;
text-align: center;
background: #fff;
border: 1px solid #f00;
border-bottom: 3px solid #f00;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}
h1,
h2,
h3 {
color: #266080;
line-height: 1.5;
}
h1:first-child,
h2:first-child,
h3:first-child {
margin-top: 0;
}
p {
font-size: 1.4em;
line-height: 1.5;
color: #266080;
}
p:last-child {
margin-bottom: 0;
}
::-webkit-scrollbar {
-webkit-appearance: none;
width: 10px;
background: #f1f3f5;
border-left: 1px solid #d3d9e0;
}
::-webkit-scrollbar-thumb {
background: #b5c0cb;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<button class="btn btn-primary btn-modal" data-toggle="modal" data-target="#ehModal">View Fullscreen Modal</button>
<div id="ehModal" class="modal" tabindex="-1" role="dialog" aria-labelledby="ehModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 id="ehModalLabel" class="modal-title">
Modal Title
</h1>
</div>
<div class="modal-body">
<h2>1. Modal Sub-Title</h2>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with
desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<h2>2. Modal Sub-Title</h2>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with
desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<h2>3. Modal Sub-Title</h2>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with
desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<h2>4. Modal Sub-Title</h2>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with
desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<h2>5. Modal Sub-Title</h2>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with
desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="container">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer
took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset
sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the
industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially
unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy
text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five
centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like
Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type
and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing
Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard
dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the
printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries,
but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker
including versions of Lorem Ipsum.</p>
</div>
答案 2 :(得分:0)
您可以使用max-height: calc(100% - 120px);
执行此操作
我希望这将有所帮助。
JSFiddle