如何使用“em”显示图像单元? [英] How can I display an image using the "em" unit?
本文介绍了如何使用“em”显示图像单元?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用 width:10em
和高度创建了一个
。< div>
:5em
现在,我想在此<$ c中显示< img>
$ c>< div> 具有完全相同的大小。
但显然它不知道 em
单位。
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.
如何显示此< img>
使用em单位?
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测试版。
It works in Firefox 3.5, Internet Explorer 8 and Opera 10.0 Beta on Windows XP.
这篇关于如何使用“em”显示图像单元?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文