gpt4 book ai didi

html - 将图像与文本垂直对齐,包括 ie

转载 作者:太空宇宙 更新时间:2023-11-04 15:24:10 24 4
gpt4 key购买 nike

执行此操作的最佳方法是什么?

这是我的 html:

<div id="wrapper">
<img src="http://i.imgur.com/b8xFk.jpg" /> <span id="text">Twitter</span>
</div>

和我的CSS:

#wrapper{
background-color:orange;
height:60px;
padding: 10px;
}

#wrapper img{
vertical-align:middle;
}

#wrapper #text{
line-height:60px;
}

还有一个 jsfiddle

如您所见,图像低于文本(至少在 Firefox 16 中)。在 ie 中,事情变得更加不稳定。将图像与文本垂直对齐以实现跨浏览器兼容性的最佳做法是什么?

提前致谢。

最佳答案

试试这个:

#wrapper img{
vertical-align:middle;
/*New:*/
padding-bottom:4px;
}

Demo

关于html - 将图像与文本垂直对齐,包括 ie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14227281/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com