Home >Web Front-end >CSS Tutorial >How to Vertically Center a Container Using Bootstrap and Other Methods?
Flexible box layout offers a straightforward solution for vertical alignment. It is widely supported by modern web browsers, except for Internet Explorer 8 and 9.
Create a class called .vertical-center and add it to the .jumbotron div.
.vertical-center { min-height: 100%; min-height: 100vh; display: flex; align-items: center; }
For legacy browsers like Internet Explorer 8 and 9, we can use pseudo-elements and vertical alignment.
.vertical-center { height:100%; width:100%; text-align: center; font: 0/0 a; } .vertical-center:before { content: " "; display: inline-block; vertical-align: middle; height: 100%; } .vertical-center > .container { max-width: 100%; display: inline-block; vertical-align: middle; font: 16px/1 "Helvetica Neue", Helvetica, Arial, sans-serif; }
The above is the detailed content of How to Vertically Center a Container Using Bootstrap and Other Methods?. For more information, please follow other related articles on the PHP Chinese website!