A Modal is a child form that overrides the parent form. Typically, the goal is to display content from a separate source, and there can be some interaction without leaving the parent form. Sub-forms can provide information exchange and so on. The following example creates a simple modal box effect: Use We can add The size class is placed in Full screen display Use Use Class Description Full screen display below 576px size Full screen display below 768px size Full screen display below 992px size Full screen display below 1200px size Full screen display below 1400px size Use By default, if the modal box contains a lot of content, the page automatically generates a scroll, and the modal box scrolls as the page scrolls: If we just want to set a scroll bar in the modal box, we can use the 7.24.1. How to create a modal box ¶
Example ¶
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#myModal">
Open Modal Box
</button>
<!-- Modal Box -->
<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Box Head -->
<div class="modal-header">
<h4 class="modal-title">Modal Box Title</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<!-- Modal Box Content -->
<div class="modal-body">
Modal Box Content..
</div>
<!-- At the bottom of the modal box -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-bs-dismiss="modal">close</button>
</div>
</div>
</div>
</div>
7.24.2. Add Animation ¶
.fade
class can set the effect that the modal box pops up or closesExample ¶
<!-- Add animation effects -->
<div class="modal fade"></div>
<!-- Do not use animation effects -->
<div class="modal"></div>
7.24.3. Modal frame size ¶
.modal-sm
class to create a small modal box
.modal-lg
class can create a large modal box.
<div>
of the element
.modal-dialog
after class:Example-small modal box ¶
<div class="modal-dialog modal-sm">
Example-large modal box ¶
<div class="modal-dialog modal-lg">
Example-extra large modal box ¶
<div class="modal-dialog modal-xl">
.modal-fullscreen
class allows the modal box to be displayed full screen:Example-full screen display ¶
<div class="modal-dialog modal-fullscreen">
.modal-fullscreen-*-\*
class can control the size of the full-screen display:
.modal-fullscreen-sm-down
.modal-fullscreen-md-down
.modal-fullscreen-lg-down
.modal-fullscreen-xl-down
.modal-fullscreen-xxl-down
7.24.4. Mode frame center display ¶
.modal-dialog-centered
class can set the horizontal and vertical orientation of the modal box to be centered:Example ¶
<div class="modal-dialog modal-dialog-centered">
7.24.5. Modal frame scroll bar ¶
Example ¶
<div class="modal-dialog">
.modal-dialog-scrollable
class:Example ¶
<div class="modal-dialog modal-dialog-scrollable">