开发者

Vertically center align text

Ok, here's what this HTML elements looks like right now:

Vertically center align text

I'd like the text to be centered with the image. The image is 32x32px.

Here's my code:

<style>
div.interface {
    line-height: 32px;
    float: left;
    margin: 10px;
    width: 450px;
    font: 14px/27px 'CalibriRegular', Ar开发者_StackOverflow中文版ial, sans-serif;
    color: #646464; text-shadow: 1px 1px 1px #fff;
    padding-right: 10px;
}
</style>

<div class="interface"><img src="assets/icons/interface.png" />Filled with fun animations and eye-candy!  Complete with Retina graphics.</div>


To center text vertically set the line-height to the same as the height, for example:

img{ height: 30px; }
#text{ line-height: 30px; }

And set vertical-alignment to middle:

#text{ line-height: 30px; vertical-align:middle; }


Add style="vertical-align: middle" to your <img /> tag.

See http://phrogz.net/CSS/vertical-align/index.html for a full explanation about the vertical-align tag.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜