How to set/make the bootstrap modal width dynamic to its content
display:inline-block elements get dynamic width regarding their content
Add the following css to your page
.modal-dialog { max-width: 100%; width: auto !important; display: inline-block; }
Now add the following code to open the modal in center
.modal{ text-align: center; }
It was indeed helpful
For me,
.modal {
text-align: -webkit-center;
}
worked as text-align: center centered the text contents of the modal also to the middle 🙂