Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resize Twitter Bootstrap modal dynamically based on the content

I have database content which has different types of data, such as Youtube videos, Vimeo videos, text, Imgur pictures, etc. All of them have different heights and widths. All I have found while searching the Internet is changing the size to only one parameter. It has to be same as the content in the popup.

This is my HTML code. I also use Ajax to call the content.

<div id="modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">     <div class="modal-header">         <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>         <h3 id="ModalLabel"></h3>     </div>     <div class="modal-body">      </div> </div>  
like image 672
Erdem Ece Avatar asked Apr 22 '13 16:04

Erdem Ece


People also ask

How do I change the size of a bootstrap modal?

Change the size of the modal by adding the . modal-sm class for small modals, . modal-lg class for large modals, or . modal-xl for extra large modals.

How can I make my modal height responsive?

Making your Modal Responsive The most obvious way is to write a bunch of media queries like a chump. I instead suggest using max-width and max-height. When combined with calc() this allows you to have a consistent padding between the modal and the edge of the screen on smaller devices.

Is bootstrap modal responsive?

Bootstrap modals are supposed to be responsive by default. Something to look out for is if you have a width set on your Modal.


1 Answers

This worked for me, none of the above worked.

.modal-dialog{     position: relative;     display: table; /* This is important */      overflow-y: auto;         overflow-x: auto;     width: auto;     min-width: 300px;    } 
like image 183
Amit Shah Avatar answered Nov 07 '22 03:11

Amit Shah