Looking for a solution to align vertically in a basic navigation list bar, particularly when some items have two lines of text.
I want the text to be vertically aligned to the middle, while still maintaining the ability to hover and click within the list block.
The HTML structure is as follows:
<div class="nav">
<ul>
<li><a href="/">Home</a></li>
<li><a href="/">Some Text</a></li>
<li><a href="/">Double<br>Line</a></li>
<li><a href="/">Something</a></li>
</ul>
</div>
The corresponding CSS styling is shown below:
.nav li {
float: left;
}
.nav a {
background: #000;
display: block;
padding: 10px;
text-decoration: none;
border-right: 2px solid #fff;
font-size: 14px;
text-align: center;
color: #fff;
}
.nav a:hover {
background: yellow;
color: #000;
}
For further clarification, see this example: http://jsfiddle.net/ZmpXM/
Cheers!