Reputation: 6338
It's pretty simple, I have a button, I want an icon to the left of it. The problem is that the button text is pushed downwards a little, so the icon and the text don't line up neatly. I'm not really sure what causes this, I tried vertical-align and setting the line-height.
http://codepen.io/anon/pen/EKlFb
<button>
<img src="http://img.informer.com/icons/png/16/3995/3995186.png"/>OBS
</button>
button {
font-weight: bold;
height: 27px;
line-height: 27px;
vertical-align: middle;
}
Upvotes: 1
Views: 91
Reputation: 8091
Just float your image to the left and it should be fixed:
HTML:
<button>
<img src="http://img.informer.com/icons/png/16/3995/3995186.png" alt="" class="icon"/>
OBS
</button>
CSS:
button {
font-weight: bold;
height: 27px;
}
button > .icon
{
float: left;
}
Upvotes: 2
Reputation: 3089
Try following:
<button>
<img src="http://img.informer.com/icons/png/16/3995/3995186.png" alt="" class="icon"/>
<span>OBS</span>
</button>
CSS:
button img,
button span {
vertical-align: middle;
}
Editted:
Upvotes: 2