I have this HTML code:
<div class="news_item">
<div class="featured_leftpart">
<img src="" width="48" height="48" />
</div>
<div class="featured_rightpart">
<div class="news_content">
<h2 class="entry-title"><a href="" >TEXT </a></h2>
</div>
</div>
</div>
and using this CSS:
.news_item
{
width:300px;
position:relative;
padding:10px;
height:100px;
margin:10px;
border:1px solid #e8e8e8;
}
div.featured_leftpart
{
position:relative;
float:left;
width:64px;
height:100%;
}
div.featured_leftpart img{
position:absolute;
background-color:#ff00ff;
top:0;
bottom:0;
left:0;
right:0;
margin:auto;
}
div.featured_rightpart
{
background-color:#ff0000;
float:left;
width:180px;
padding-left:10px;
height:100%;
}
.news_content
{
background-color:#00ff00;
position:relative;
}
.news_content h2
{
vertical-align:middle;
}
What I'm trying to do is to vertical align h2 tag. This tag will contain a post title, so sometimes it will be single line, sometimes multiline.
Also that <div class="news_content">
is just my attempt to make it work. If there is a solution without this div
, I can easily remove it.
Here is jsFiddle link to the code above.