Saved Bookmarks
| 1. |
Add a fading effect when opening and closing the Bootstrap modal |
|
Answer» To add fading effect for a BOOTSTRAP Modal, use the .fade class. Add this class in the modal container <div class="modal fade" id="newModal">Let US see an example of Bootstrap modal fading effect: <!DOCTYPE html> <html lang="en"> <head> <TITLE>Bootstrap Modal</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <LINK rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Modal in Bootstrap</h2> <p>Fading effect in Modal...</p> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#newModal"> Open </button> <div class="modal fade" id="newModal"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title">Modal Heading</h4> <button type="button" class="close" data-dismiss="modal">×</button> </div> <div class="modal-body"> Body of the modal... </div> <div class="modal-footer"> <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button> </div> </div> </div> </div> </div> </body> </html>The output looks like this: On clicking the “Open” button, the modal opens and the fading effect is visible. The same fading effect can be seen on closing the modal: |
|