Reputation: 915
How to set twitter bootstrap modal wider and higher?
Example here (please click: Launch demo modal):
http://twitter.github.com/bootstrap/javascript.html#modals
Upvotes: 38
Views: 89183
Reputation: 4510
Following works without viewport breakpoints and also for older bootstrap modals:
#myModal{
position: fixed;
left: 10% !important;
right: 10% !important;
top: 10% !important;
width: 80% !important;
margin: 0 !important;
}
Upvotes: 0
Reputation: 415
css:
.modal-lg, .modal-sm {
min-width: 90%;
}
code:
<!-- The Modal -->
<div class="modal fade" id="myModal">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Modal Heading</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
Modal body..
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Upvotes: 2
Reputation: 456
The accepted answer works well, however I would recommend using padding rather than margin. This way you retain the dismiss functionality when you click outside of the modal dialog.
#myModal {
width: 700px;
padding-top: -300px !important;
padding-left: -350px !important;
}
#myModal .modal-body {
max-height: 525px;
}
Upvotes: 4
Reputation: 102448
In Bootstrap 3.1.1 they added modal-lg
and modal-sm
classes. You control the modal
size using @media
queries like they do. This is a more global way of controlling the modal
size.
@media (min-width: 992px) {
.modal-lg {
width: 900px;
height: 900px; /* control height here */
}
}
Sample code:
<!-- Large modal -->
<button class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-lg">Large modal</button>
<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
...
</div>
</div>
</div>
<!-- Small modal -->
<button class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-sm">Small modal</button>
<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
...
</div>
</div>
</div>
Upvotes: 56
Reputation: 353
altering class model-dialog did the trick for me
.modal-dialog {
width: 90%;
}
Upvotes: 9
Reputation: 1315
The easiest way to do this is to use the .modal-lg. Add it to the modal-dialog class within the modal container like so:
<div class="modal fade">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
I am now wider!
</div>
</div>
</div>
Upvotes: 12
Reputation: 3463
Either of the following solutions worked for me:
Applying style="width: 50%; height:50%;"
to the div
in the modal section with the class="modal-dialog"
like so
<div class="modal-dialog" style="width: 50%; height:50%;">
or
Creating a style section like so
#themodal .modal-dialog{ width:50%; height:50%;}
Upvotes: -1
Reputation: 1017
For a size in %, you could do this:
.modal-body
{
max-height:80%;
}
.modal
{
height:80%;
width:70%;
margin-left: -35%;
}
@media (max-width: 768px) {
.modal
{
width:90%;
margin-left: 2%;
}
}
Upvotes: 10
Reputation: 5284
If your modal id is "myModal "
You could try adding a style like:
#myModal
{
width: 700px;
margin-top: -300px !important;
margin-left: -350px !important;
}
#myModal .modal-body {
max-height: 525px;
}
Upvotes: 27
Reputation: 7437
In your css file, add a new class definition:
.higherWider {
width:970px;
margin-top:-250px;
}
In your HTML, add higherWider
inside the class string for your modal:
<div class="modal hide fade higherWider">
Upvotes: 5
Reputation: 193301
With CSS:
.modal {
width: 900px;
margin-left: -450px; // half of the width
}
Upvotes: 1