Created
June 18, 2012 21:24
-
-
Save llkats/2950815 to your computer and use it in GitHub Desktop.
list links in boxes; vertically centered text with one or two lines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
li { | |
display: block; | |
height: 50px; | |
line-height: 50px; /* line-height is the same as the height of this element */ | |
text-align: center; | |
width: 140px; | |
} | |
li a { | |
display: block; /* fills the li */ | |
border: 1px solid #CCC; | |
font-size: 14px; | |
} | |
li a:hover { | |
background: transparent; | |
border: 1px solid #39C; | |
color: #39C; | |
} | |
li span { | |
display: inline-block; /* inline-block and resetting line-height lets the magic happen */ | |
line-height: normal; | |
vertical-align: middle; /* vertical-align makes the magic happen */ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- thanks to this stack overflow question for setting me on the right path: http://stackoverflow.com/questions/4095165/center-single-and-multi-line-li-text-vertically --> | |
<ul> | |
<li> | |
<a href="#"> <!-- needs to fill containing li --> | |
<span>link text</span> <!-- needs to be vertically centered --> | |
</a> | |
</li> | |
<li> | |
<a href="#"> | |
<span>some really long link text that will break across two lines</span> | |
</a> | |
</li> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment