垂直居中对齐文本 [英] Vertically center align text

查看:131
本文介绍了垂直居中对齐文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,这里的HTML元素现在看起来像:

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

我想让文本与图片居中。图片为32x32像素。

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

这是我的代码:

<style>
div.interface {
    line-height: 32px;
    float: left;
    margin: 10px;
    width: 450px;
    font: 14px/27px 'CalibriRegular', Arial, 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>


推荐答案

与高度相同,例如:

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

并将垂直对齐设置为中间:

And set vertical-alignment to middle:

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

这篇关于垂直居中对齐文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆