How to Vertically Center Text With CSS

Some works with CSS sometimes may be weird. I spend hours to make a text to make it vertically align within a DIV tag. Finally, I found a solution at Stack Overflow.

Example HTML code:

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

CSS solution for how to align text vertically:

div {
 width: 250px;
 height: 100px;
 line-height: 100px;
 text-align: center;
 }

span {
 display: inline-block;
 vertical-align: middle;
 line-height: normal;
 }

Link: http://stackoverflow.com/questions/8865458/how-to-align-text-vertically-center-in-div-with-css

 

 

Add a Comment

Your email address will not be published. Required fields are marked *