HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
The Modal component is a dialog box/popup window that is displayed on top of the current page
The Modal component is a dialog box/popup window that is displayed on top of the current page:
Open modal
The following example shows how to create a basic modal:
<!-- Button to Open the Modal -->
<button type="button" class="btn btn-primary"
data-toggle="modal" data-target="#myModal">
Open modal
</button>
<!-- The Modal -->
<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal
Header -->
<div class="modal-header">
<h4 class="modal-title">Modal Heading</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
Modal
body..
</div>
<!-- Modal footer -->
<div
class="modal-footer">
<button
type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Use the .fade
class to add a fading effect when opening and closing the modal:
<!-- Fading modal -->
<div class="modal fade"></div>
<!--
Modal without animation -->
<div class="modal"></div>
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.
Add the size class to the <div>
element with class .modal-dialog
:
<div class="modal-dialog modal-sm">
<div class="modal-dialog modal-lg">
<div class="modal-dialog modal-xl">
By default, modals are "medium" in size.
Center the modal vertically and horizontally within the page, with the .modal-dialog-centered
class:
<div class="modal-dialog modal-dialog-centered">
When you have a lot of content inside the modal, a scrollbar is added to the page. See the examples below to understand it:
<div class="modal-dialog">
However, it is possible to only scroll inside the modal, instead of the page itself, by adding .modal-dialog-scrollable
to .modal-dialog
:
<div class="modal-dialog modal-dialog-scrollable">
For a complete reference of all modal options, methods and events, go to our Bootstrap JS Modal Reference.