【发布时间】:2016-07-22 01:21:30
【问题描述】:
我在 HTML 中创建图像标签
var img = document.getElementById('image');
alert(img.width)
<div width="500">
<img id="image" width="100%" height="1"></img>
</div>
在所有浏览器中 img.width 将为 500px。但是在 Firefox 中它会是 0。但是如果在图像标签中设置 src 就可以了。
是否可以在不使用任何文件的情况下设置1px透明图像(png,jpg,...)
【问题讨论】:
-
您可以使用数据 url:css-tricks.com/snippets/html/… 这可能是最有效的方式。