好的,这是这个 HTML 元素现在的样子:
我希望文本以图像为中心。图片大小为 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; }
并将垂直对齐设置为中间:
#text{ line-height: 30px; vertical-align:middle; }
关于html - 垂直居中对齐文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4952943/