I am trying to create a self-adjusting horizontal menu and looking to vertically align text within li
's that are displayed as inline
. Currently the text is glued to the top. All my attempts have failed. See markup below.
#nav
{
display: inline-table;
padding: 0;
margin-top: 10em;
margin-bottom: 10em;
}
#nav > li
{
display: inline;
float: left;
height: 8em;
width: 8em;
padding: 0px 5px;
font-size: 1.5em;
color: #0a547c;
}
#nav > li:hover
{
background-color: blue;
cursor: pointer;
}
<div style="text-align: center; height: 30em;">
<ul id="nav">
<li onclick="window.open('myLink1', '_self');">Text A</li>
<li onclick="window.open('myLink2', '_self');">Text B</li>
</ul>
</div>
I don't want to use line-height
because the text may wrap.