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!