About Lesson
Centering Modals & Fullscreen Modals
- .modal-dialog-centered → Centers the modal vertically
- .modal-fullscreen → Makes the modal full screen
Example: Centered & Fullscreen Modal
HTML
<!-- Centered Modal -->
<button type="button" class="btn btn-warning" data-bs-toggle="modal" data-bs-target="#centerModal">Centered Modal</button>
<div class="modal fade" id="centerModal">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Centered Modal</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
This modal is centered vertically.
</div>
</div>
</div>
</div>
<!-- Fullscreen Modal -->
<button type="button" class="btn btn-dark" data-bs-toggle="modal" data-bs-target="#fullscreenModal">Fullscreen Modal</button>
<div class="modal fade" id="fullscreenModal">
<div class="modal-dialog modal-fullscreen">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Fullscreen Modal</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
This modal takes up the entire screen.
</div>
</div>
</div>
</div>
Explanation:
- .modal-dialog-centered places the modal in the middle.
- .modal-fullscreen makes the modal cover the whole screen.