As per the Bootstrap documentation, the way to change Bootstrap modal size, is to add a modifier class to the .modal-dialog
element. Out of the box, Bootstrap modals can be any of 5 possible supported sizes, which are:
1. Small (.modal-sm)
2. Medium/Default (No Class)
3. Large (.modal-lg)
4. Extra-Large (.modal-xl)
5. Fullscreen (.modal-fullscreen)
Notice that there's not any Extra-Extra-Large .modal-xxl
size, despite that Bootstrap supports the XXL size as part of its native grid system. That's weird. It definitely feels like it should be there. Let's say you want to implement it, in a good Bootstrap way (without hard-coding width values in your code). I have a .modal-xxl
class which I use in my projects. Here's how I implemented it:
How To Implement An Extra-Extra Large .modal-xxl
Modal Size
- Add a
$modal-xxl
variable to your application-specific _variables.scss
. Its value needs to be the maximum possible width of the XXL grid breakpoint. To do this, use map-get
and take the xxl
value of the $container-max-widths
array map. Now if for some reason your application XXL grid size ever changes, this will update too. NOTE: The default value Bootstrap has set for this is 1320px.
$modal-xxl: map-get($container-max-widths, 'xxl') !default;
- Now you must add the following code to your application-specific SCSS:
@include media-breakpoint-up(lg) {
.modal-xxl {
--#{$variable-prefix}modal-width: #{$modal-lg};
}
}
@include media-breakpoint-up(xl) {
.modal-xxl {
--#{$variable-prefix}modal-width: #{$modal-xl};
}
}
@include media-breakpoint-up(xxl) {
.modal-xxl {
--#{$variable-prefix}modal-width: #{$modal-xxl};
}
}
That's It!
Now, you can make your modal be XXL size simply by adding the .modal-xxl
modifier class to your .modal-dialog
, and your modal will now be an Extra-Extra Large size.
@media screen and (min-width:768px){.modal-dialog{width:600px;margin:30px auto}
- could that fixed width be causing my issue? – Danczyk