Bootstrap Scrollable Modal
Bootstrap Scrollable Modal:A Bootstrap scrollable modal is a type of modal window that allows content to be displayed within a fixed-size container with a scrollable area. It combines the features of a modal dialog box and a scrollable element. This means that when the modal contains more content than can fit within its fixed size, a scrollbar is added, allowing users to scroll and view the hidden content. Bootstrap provides built-in CSS classes and JavaScript functions to create a scrollable modal easily. By implementing a Bootstrap scrollable modal, developers can present large amounts of information in a structured and user-friendly manner.




Thanks for your feedback!
Your contributions will help us to improve service.
How can I create a scrollable modal using Bootstrap classes?
The "modal-dialog-scrollable" class in Bootstrap allows for creating a scrollable modal dialog.
When applied to the modal dialog container, it enables a scrollbar within the modal when its content exceeds the available height.
This class ensures that the modal remains within the viewport while providing a scrollable area for content that goes beyond the modal's visible area
Bootstrap Scrollable Modal using bootstrap class Example
xxxxxxxxxx
<!-- Button to trigger the modal -->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#myModal">
Open Modal
</button>
<!-- The Modal -->
<div class="modal fade" id="myModal" tabindex="-1" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-scrollable modal-dialog-centered">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">Bootstrap Scrollable Modal</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<!-- Modal Body -->
<div class="modal-body">
<!-- Add your content here -->
<img src="https://www.sarkarinaukriexams.com/images/editor/1685126932elon-musk-g2eacd7b5f_640.png"
class="img-fluid rounded" alt="Bootstrap Image">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur vitae placerat magna. Nunc
tempus,
est sed dictum vestibulum, ipsum elit aliquet enim, vel rutrum sem nisi nec mauris.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur vitae placerat magna. Nunc
tempus,
est sed dictum vestibulum, ipsum elit aliquet enim, vel rutrum sem nisi nec mauris.</p>
<!-- Repeat the above paragraph as needed -->
</div>
<!-- Modal Footer -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Output of Bootstrap Scrollable Modal
How can I create a scrollable modal using custom CSS in Bootstrap?
To create a Bootstrap scrollable modal with custom CSS, you can use the following example :
In this example, the CSS rule ".modal-body" is targeted. It sets the maximum height of the modal body to 300 pixels and enables vertical scrolling if the content exceeds this height.
This allows the modal to display a fixed height and provide a scrollable area for the content within it.
Bootstrap Scrollable Modal using Custom Css Example
xxxxxxxxxx
<style>
/* Add the custom CSS rules here */
.modal-body {
max-height: 300px;
overflow-y: auto;
}
</style>