Reputation: 2327
How would I go about vertically centering multiple lines of text in a button that has a specified width and height?
<a href="#">This text will take up two lines</a>
a {
display: inline-block
height: 50px;
width: 100px;
}
Upvotes: 0
Views: 1643
Reputation: 11058
Use line-height
:
a { line-height: 50px; }
This only works if the text takes up one line. If you have to deal with mulitple lines, you could make use of display: table-cell
:
a { display: table-cell; vertical-align: middle; }
Upvotes: 2
Reputation:
it would be best to use % or em when dealing with line-height. Different browsers render text (size) differently; when you use % it adjusts auto accordingly.
a { line-height: 1.3em; }
Upvotes: 0