-
Basic Modal
Toggle a working modal demo by clicking the button below. It will slide down and fade in from the top of the page.
Scrolling Long Content
When modals become too long for the user’s viewport or device, they scroll independent of the page itself. Try the demo below to see what we mean.
Vertically Centered
Add
.modal-dialog-centered
to.modal-dialog
to vertically center the modal.Tooltips and Popovers
Tooltips and popovers can be placed within modals as needed. When modals are closed, any tooltips and popovers within are also automatically dismissed.
Colored Modals
Add
.modal-*
to.modal
for different background color.Modal Sizes
Add
.modal-lg
ormodal-sm
to.modal-dialog
for different size. -
Varying Modal Content
Have a bunch of buttons that all trigger the same modal with slightly different contents? Use
event.relatedTarget
and HTMLdata-*
attributes to vary the contents of the modal depending on which button was clicked.$('#exampleModal').on('show.bs.modal', function (event) { var button = $(event.relatedTarget) // Button that triggered the modal var recipient = button.data('whatever') // Extract info from data-* attributes // If necessary, you could initiate an AJAX request here (and then do the updating in a callback). // Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead. var modal = $(this) modal.find('.modal-title').text('New message to ' + recipient) modal.find('.modal-body input').val(recipient) })