Ask any question about Bootstrap here... and get an instant response.
Post this Question & Answer:
How can I customize the default Bootstrap modal transition effects?
Asked on Apr 04, 2026
Answer
To customize the default Bootstrap modal transition effects, you can override the default CSS for modal animations. Bootstrap uses CSS transitions for modals, and you can modify these by targeting the `.modal.fade` class.
<!-- BEGIN COPY / PASTE -->
<style>
.modal.fade .modal-dialog {
transition: transform 0.5s ease-out, opacity 0.5s ease-out;
transform: translateY(-50px);
opacity: 0;
}
.modal.fade.show .modal-dialog {
transform: translateY(0);
opacity: 1;
}
</style>
<div class="modal fade" id="customModal" tabindex="-1" aria-labelledby="customModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="customModalLabel">Custom Modal</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
This is a custom modal with modified transition effects.
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- END COPY / PASTE -->Additional Comment:
✅ Answered with Bootstrap 5 best practices.- The `.modal.fade .modal-dialog` class is used to set the initial state of the modal with a custom transition.
- The `.modal.fade.show .modal-dialog` class defines the final state when the modal is fully visible.
- You can adjust the `transition` properties to change the duration and easing of the animation.
- Ensure that your custom styles are loaded after Bootstrap's CSS to override the default styles.
Recommended Links:
