How can I align some text vertically in the middle of an HTML image?
I have this: http://jsfiddle.net/8KWtH/
I would like to move the > so it is i开发者_如何学Cn the middle vertically of the two images.
How can i do this?
Use line-height
to accomplish this:
<span style="font-size: 34px;line-height: 79px;"> > </span>
EDIT:
Because of the nature of the images, you need to use vertical-align
to accomplish this:
<div style="float: left;">
<img src="http://www.lokeshdhakar.com/projects/lightbox2/images/image-2.jpg" style="width: 60px; height: 79px;vertical-align: middle;">
<span style="font-size: 34px;"> > </span>
<img src="http://www.lokeshdhakar.com/projects/lightbox2/images/image-2.jpg" style="width: 60px; height: 79px;vertical-align: middle;">
</div>
You can set your images to have vertical-align:middle;
but that will make the > start from the middle. so it will still go up a little.
example: http://jsfiddle.net/8KWtH/14/
Applying the vertical align to the span as well makes it perfect.
example: http://jsfiddle.net/8KWtH/22/
I'd start by using the following instead of >.
>
I whipped out something here
From what I can see it is basically a variation on the other answers but it gets the job done
精彩评论