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
Barbara StreisandOriginal
2024-12-06 02:47:09690browse

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;
}

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!

Statement:
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