如何使用& quot; em& quot;来显示图像单元? [英] How can I display an image using the "em" unit?
本文介绍了如何使用& quot; em& quot;来显示图像单元?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个< div>
,其宽度为 width:10em
和 height:5em
.
现在,我想在此< div>
中以完全相同的大小显示< img>
(GIF图像).但是显然,它不知道" em
单元.而是以10x5个像素显示图片.
I've created a <div>
with width:10em
and height:5em
.
Now I would like to display an <img>
(GIF image) in this <div>
with the exact same size.
But apparently it doesn't "know" the em
unit. It shows the picture in 10x5 pixels instead.
如何使用"em"单元显示此< img>
?
How can I display this <img>
using the "em" unit?
推荐答案
使用以下代码:
<html>
<body>
<p>This is 10em x 5em</p>
<div style="width:10em; height:5em;">
<img style="width:10em; height:5em;" src="logo.png" />
</div>
</body>
</html>
它可以在Windows XP的Firefox 3.5,Internet Explorer 8和Opera 10.0 Beta中使用.
It works in Firefox 3.5, Internet Explorer 8 and Opera 10.0 Beta on Windows XP.
这篇关于如何使用& quot; em& quot;来显示图像单元?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文