Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shift img few pixels up or down

Tags:

html

css

This seems trivial, but I cannot find anything. I have a text and small image (icon) inside the text like this:

<span>ask<img src=ask.svg height=16> fav<img src=fav.svg> voted</span>

All I need is to move the image few pixels up or down to look better with the text.

I tried CSS styles like margin-top:3px, padding-top:3px, display:absolute, display:relative and some others, but nothing works.

UPDATE: I do not need vertical align to middle. Yes, it looks better, but I still want to be able to shift the image a few pixels manually. So my question remains: how to fine tune the image vertical position within the text by a few pixels in any direction.

enter image description here

like image 360
exebook Avatar asked Oct 28 '25 10:10

exebook


1 Answers

You can set position: relative for img, then move it with top or bottom http://jsfiddle.net/kencoder97/xu4158fL/

An example to move an image upwards by a couple of pixels would be

<img src="my_image.jpg" style="position: relative; bottom: 2px">
like image 113
Cuong Vu Avatar answered Oct 30 '25 00:10

Cuong Vu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!