This is the standard code I use to align elements vertically inside the parent element:
HTML
<div id="header">
<img src="http://cdn.flaticon.com/png/256/60510.png" />
</div>
CSS
#header{
border: 1px solid red;
height: 30px;
}
img{
height:20px;
vertical-align: middle;
}
#header:before,
.frame_before {
content: "";
display: inline-block;
height: 100%;
vertical-align: middle;
}
It works OK but when I want to float the img to the right with float:right, the img is not vertically aligned anymore.
http://jsfiddle.net/uvpfedt6/1/
How should I modify my code to align the floated img vertically?