Home > Web Front-end > CSS Tutorial > How Can I Vertically Center Content in Twitter Bootstrap 3?

How Can I Vertically Center Content in Twitter Bootstrap 3?

Barbara Streisand
Release: 2024-12-06 02:47:09
Original
689 people have browsed it

How Can I Vertically Center Content in Twitter Bootstrap 3?

Vertically Centering Content in Twitter Bootstrap 3

Many users have encountered challenges in vertically centering text and images within Twitter Bootstrap 3. This article provides a solution that leverages responsive and dynamic content.

One approach is to utilize the display:inline-block property instead of float. This allows content to align vertically while maintaining the ability to respond to different screen sizes. By incorporating vertical-align:middle, both text and images will be centered vertically.

To implement this solution, simply add the following CSS:

.col-lg-4, .col-lg-8 {
    float:none;
    display:inline-block;
    vertical-align:middle;
    margin-right:-4px;
}
Copy after login

This will center both text and images, regardless of their relative sizes.

A working demonstration is available at http://bootply.com/94402, showcasing how the content responds dynamically to screen resolution changes while maintaining vertical alignment.

The above is the detailed content of How Can I Vertically Center Content in Twitter Bootstrap 3?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template