In my application I am using bootstrap $modal
popup two different times. content of both pop-ups is different hence size of both pop-up must be also different. I tried to style $modal
using
.modal {
display: block;
position: absolute;
left: 60%;
height: 88%;
width: 28%;
overflow-y:auto;
overflow-x:auto;
border-radius: 0px;
}
but as expected it is changing style of both of my pop-ups. Is there any way to apply different class to each popup?
Thanks in advance.
Use the.modal-body class in Bootstrap to style the modal. You can try to run the following code to style modal −/p>
The .close class styles the close button, and the .modal-title class styles the header with a proper line-height. The .modal-body class is used to define the style for the body of the modal. Add any HTML markup here; paragraphs, images, videos, etc. The .modal-footer class is used to define the style for the footer of the modal.
If you want to customize your Bootstrap site, you can leave the source code as is and simply add custom code in an external stylesheet. The code in this external stylesheet will override the existing styles — as long as it’s set up properly. This set-up process differs slightly, depending on how you load Bootstrap on your site.
The.modal-body class is used to define the style for the body of the modal. Add any HTML markup here; paragraphs, images, videos, etc. The.modal-footer class is used to define the style for the footer of the modal. Note that this area is right aligned by default.
If you have access to HTML, Then you can add an extra class to the modal like <div class="modal custom">
then you can style it like .modal.custom
. Full example below
Working Demo
HTML
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal2">
Variable Modal
</button>
<!-- Modal -->
<div class="modal custom fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
....
CSS
.modal.custom .modal-dialog {
width:50%;
margin:0 auto;
/*add what you want here*/
}
Let me know if you have further issues in the comments.
Update 2017 - Bootstrap 4
The structure of the modal has changed since Bootstrap 3, so now different CSS is required to customize the position, size or modal styles. To change the modal width, set the max-width
on the modal-dialog
, for exmaple:
.modal.custom .modal-dialog {
max-width: 50%;
}
Custom modal demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With