I need to style a fixed-height container with a width of 100% that is set to display:block
.
Inside this container, there are two text elements styled differently in terms of font-size
, and floated left and right respectively.
Here's the HTML structure:
<header>
<h1 class="right">Title</h1>
<h2 class="left">Slogan</h2>
</header>
And here's the CSS styling:
header{ position:fixed; width:100%; height:5em; }
header h1{ font-size:3em; margin:0; }
header h2{ font-size:2em; margin:0; }
I am trying to vertically center these text elements without using display:table-cell
. Since the font-size
s are different and specified in em units rather than pixels, I also cannot resort to using line-height
.
Is there a way to achieve vertical centering for these text elements?