开发者

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;"> &gt; </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;"> &gt; </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 >.

&gt;


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜