I'm trying to vertically center a row of cells in an absolutely-positioned div. The height of the div is determined by an inline-block element immediately preceding the table.
I want to keep the .title
out of the table because I'd like the entire menu to break to the next line if the screen isn't wide enough.
I've tried defining the height and the line height, applying padding, and giving the .menu-box
element display:table-cell
and vertical-align:middle
, but nothing seems to be working.
Here's the code:
<div class="container">
<div class="menu-box">
<h1 class="title">TITLE</h1>
<table class="menu"><tr>
<td>Item 1</td>
<td>Item 2</td>
<td>Item 3</td>
<td>Item 4</td>
</tr></table>
</div>
</div>
CSS:
* {margin:0;padding:0;}
body,html {height:100%;width:100%;}
.container {
position:relative;
height:100%;
}
.menu-box {
position:absolute;
bottom:0;
width:100%;
// line-height:132px;
}
.title {
display:inline-block;
font-size:132px;
}
.menu {
display:inline-table;
font-size:26px;
// padding:40px 0;
}
And a Fiddle