Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to make bootstrap modal wider

I am using this code but the modal is too thin:

<div class="modal fade bs-example-modal-lg custom-modal" tabindex="-1" role="dialog" aria-labelledby="myModal" aria-hidden="true" id="myModal">     <div class="modal-dialog modal-lg">         <div class="modal-content modal-lg">             <div class="modal-header modal-lg">                 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>                 <h4 class="modal-title">Solutions</h4>             </div>             <div class="modal-body modal-lg">                 <p>Content</p>             </div>         </div>     </div> </div> 

This is what it looks like:

Thin modal

How can I make that modal much wider? Ideally I'd like it to be around double that width as it is too skinny at the moment.

like image 690
b85411 Avatar asked Sep 16 '14 01:09

b85411


People also ask

How do I make my Bootstrap 5 modal bigger?

Change the size of the modal by adding the . modal-sm class for small modals (max-width 300px), . modal-lg class for large modals (max-width 800px), or . modal-xl for extra large modals (max-width 1140px).

How do you fix modal height?

modal-body use calc() function to calculate desired height. In above case we want to occupy 80vh of the viewport, reduced by the size of header + footer in pixels. This is around 140px together but you can measure it easily and apply your own custom values. For smaller/taller modal modify 80vh accordingly.

How do you reduce the width of a modal?

Answer: Set width for . modal-dialog element Similarly, you can override the width property of . modal-sm , . modal-lg and . modal-xl class to resize the small, large and extra-large modal dialog box respectively.


1 Answers

Always have handy the un-minified CSS for bootstrap so you can see what styles they have on their components, then create a CSS file AFTER it, if you don't use LESS and over-write their mixins or whatever

This is the default modal css for 768px and up:

@media (min-width: 768px) {   .modal-dialog {     width: 600px;     margin: 30px auto;   }   ... } 

They have a class modal-lg for larger widths

@media (min-width: 992px) {   .modal-lg {     width: 900px;   } } 

If you need something twice the 600px size, and something fluid, do something like this in your CSS after the Bootstrap css and assign that class to the modal-dialog.

@media (min-width: 768px) {   .modal-xl {     width: 90%;    max-width:1200px;   } } 

HTML

<div class="modal-dialog modal-xl"> 

Demo: http://jsbin.com/yefas/1

like image 151
Christina Avatar answered Oct 10 '22 10:10

Christina