Bootstrap 5 Modal Vertically Centered Last Updated : 02 Aug, 2024 Comments Improve Suggest changes Like Article Like Report Bootstrap 5 Modal Vertically Centered is used to make the modal centered aligned. Modals are positioned over everything else in the document and the scroll gets removed from the <body> so that modal content scrolls instead. Using bootstrap modal classes we can make the modal body align vertically centered.Bootstrap 5 Modal Vertically Centered Classes:modal-dialog-centered: To make modal vertically centeredSyntax:<div class="modal-dialog modal-dialog-centered"> ...</div>Example 1: In this example, we will learn about Modal Vertically Centered HTML <!DOCTYPE html> <html> <head> <!-- Bootstrap CDN --> <link href= "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity= "sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> <script src= "https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity= "sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"> </script> <script src= "https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js" integrity= "sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/" crossorigin="anonymous"> </script> </head> <body> <div class="container"> <h1 class="text-success"> GeeksforGeeks </h1> <h2>Bootstrap 5 Modal Vertically centered</h2> <button type="button" class="btn btn-success" data-toggle="modal" data-target="#GFG"> Launch Vertically Centered modal </button> <div class="modal fade" id="GFG"> <div class="modal-dialog modal-dialog-centered"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title"> I am modal vertically centered </h5> </div> <div class="modal-body"> GeeksforGeeks <img src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/Java.png" height="100px" width="300px"> </div> <div class="modal-footer"> <button type="button" class="btn" data-dismiss="modal"> Close </button> <button type="button" class="btn"> Save changes </button> </div> </div> </div> </div> </div> </body> </html> OutputExample 2: In this example, we will learn about Vertically centered scrollable modal HTML <!DOCTYPE html> <html> <head> <!-- Bootstrap CDN --> <link href= "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity= "sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> <script src= "https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity= "sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"> </script> <script src= "https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js" integrity= "sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/" crossorigin="anonymous"> </script> </head> <body> <div class="container"> <h1 class="text-success"> GeeksforGeeks </h1> <h2>Bootstrap 5 Modal Vertically centered</h2> <button type="button" class="btn btn-success" data-toggle="modal" data-target="#GFG"> Launch Vertically Centered modal </button> <div class="modal fade" id="GFG"> <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title"> I am modal vertically centered </h5> </div> <div class="modal-body"> GeeksforGeeks <div class="card"> <img src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/Java.png" class="card-img-top"> <div class="card-body"> <h5 class="card-title">Java</h5> <p class="card-text"> Java is Object Oriented. However, it is not considered as pure object-oriented as it provides support for primitive data types (like int, char, etc) </p> </div> </div> <div class="card"> <img src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/Java.png" class="card-img-top"> <div class="card-body"> <h5 class="card-title">Java</h5> <p class="card-text"> Java is Object Oriented. However, it is not considered as pure object-oriented as it provides support for primitive data types (like int, char, etc) </p> </div> </div> <div class="card"> <img src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/Java.png" class="card-img-top"> <div class="card-body"> <h5 class="card-title">Java</h5> <p class="card-text"> Java is Object Oriented. However, it is not considered as pure object-oriented as it provides support for primitive data types (like int, char, etc) </p> </div> </div> <div class="card"> <img src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/Java.png" class="card-img-top"> <div class="card-body"> <h5 class="card-title">Java</h5> <p class="card-text"> Java is Object Oriented. However, it is not considered as pure object-oriented as it provides support for primitive data types (like int, char, etc) </p> </div> </div> </div> <div class="modal-footer"> <button type="button" class="btn" data-dismiss="modal"> Close </button> <button type="button" class="btn"> Save changes </button> </div> </div> </div> </div> </div> </body> </html> OutputReference: https://getbootstrap.com/docs/5.0/components/modal/#vertically-centered Comment More infoAdvertise with us Next Article Bootstrap 5 Modal Tooltips and Popovers A akshitsaxena2 Follow Improve Article Tags : Technical Scripter Web Technologies Bootstrap Technical Scripter 2022 Similar Reads Bootstrap 5 Modal Components A website can have dialogues added for lightboxes, user notifications, or entirely unique content by using Bootstrap modals. A modal is made up of components like the dialog, content, header, title, body, and footer. A modal can be used to implement a lot of utilities like showing a message or poppi 4 min read Bootstrap 5 Modal Live demo Bootstrap 5 Modal live demo demonstrates the toggle of a working modal by clicking a button that opens a modal. The modal content slides down but fades in from the top after the toggle action. Different components are assembled together to create a Modal. Modals can be triggered using the data attri 3 min read Bootstrap 5 Modal Static backdrop Bootstrap 5 Modal Static backdrop facilitates the modal that will not be going to be closed while clicking outside of the modal, by setting the backdrop to static. Modal Static backdrop Classes: There are no specific classes used in Modal Static backdrop. Although, we can create the modal using Moda 2 min read Bootstrap 5 Modal Scrolling long content Bootstrap 5 Modal Scrolling long content is used when modal body content becomes very large then it becomes scrollable. Modals can either be scrolled independently of the page or we can scroll the modal body. We will learn about them using examplesSyntax:<div class="modal-dialog modal-dialog-scro 2 min read Bootstrap 5 Modal Vertically Centered Bootstrap 5 Modal Vertically Centered is used to make the modal centered aligned. Modals are positioned over everything else in the document and the scroll gets removed from the <body> so that modal content scrolls instead. Using bootstrap modal classes we can make the modal body align vertica 3 min read Bootstrap 5 Modal Tooltips and Popovers Bootstrap 5 provides a robust way to enhance user interfaces through modals, tooltips, and popovers. These components help in displaying additional information to users without cluttering the main content. Tooltips offer brief descriptions, while popovers can contain more detailed information. Both 4 min read Bootstrap 5 Modal Using the Grid Bootstrap 5 Modal Using the grid can add content which can be anything from text to images to anything we want. We can also create layouts inside a modal too, Grid System being one of the main tools for creating responsive layout modals. So we can add different settings and variations of the Grid Sy 3 min read Bootstrap 5 Varying Modal Content Bootstrap 5 Modal Content can be varied by passing the value which needed to be accessed in the modal to a data-bs-* (where * can be anything you like) attribute of the triggering button. The value passes to the modal can be accessed using JavaScript and can be used in the modal content. Bootstrap 5 4 min read Bootstrap 5 Toggle Between Modals Bootstrap 5 Toggle Between Modals is used to switch between modals, this does not mean there can be multiple opened modals, only one modal at a time can be opened, by using this feature we can trigger the other modal that will replace the current modal content with the new ones.Bootstrap 5 Toggle be 3 min read Bootstrap 5 Modal Change Animation Bootstrap 5 Modal Change animation facilitates several variables that determine the animation transformation state of the modal, along with setting the zoom-in & zoom-out animation for the modal. The Modal opens with a fade-in animation when it is triggered using a button, although, this animati 4 min read Like