有没有办法通过CSS设置图像高度到行高? [英] Is there a way via CSS to set the image height to the line-height?
本文介绍了有没有办法通过CSS设置图像高度到行高?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个与文字内联的图片。那个图片是32x32。我想让它的自动尺寸到它的内容的行高,因此它适合正确。有办法吗?
I have an image thats inline with text. That image is 32x32. I'm looking to have it auto size to the line-height of whats its in so it fits properly. Is there a way to do that?
我希望能够将图像放在未知的行高处,并使其大小适当。
I'm looking to be able to place the image anywhere with an unknown line-height and have it size properly.
推荐答案
使用 img {height:1em;} / *无论你的行高是多少, font-size / *
查看此 更新演示 (增加或减少字体大小以查看结果。)
See this Updated Demo (Increase or decrease the font size to view the result.)
这篇关于有没有办法通过CSS设置图像高度到行高?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文