我有这个图片标签。IE和Chrome/Mozilla的图片大小各不相同。它在Chrome/Mozilla中工作得很好,但我看到IE中的图像尺寸增加了近1000%。
<img src="{% static "/static/img/left_arrow.png" %}" alt="prev" height="15" width="15" />我哪里错了?
发布于 2013-11-05 13:11:46
这是为了标准化跨浏览器(directly from normalize.css)的图像查看,以及在一个方向或另一个方向上正确缩放图像。
最后一行是修复IE缩放图像的问题。
将其放入您的CSS文件中。
img {
border: 0;
-ms-interpolation-mode: bicubic;
max-width: 100%;
height: auto;
width: auto;
width: auto\9;
}对于内联CSS:
<img style="border: 0;-ms-interpolation-mode: bicubic;max-width: 100%;height: auto;width: auto;width: auto\9;" src="{% static "/static/img/left_arrow.png" %}" alt="prev" width="15" height="15" />您不应该对超出您希望缩小到的尺寸的图像执行此操作。用户将下载完整的图像,然后调整其大小,从而浪费带宽和CPU。这个大小的图片不是什么大问题,但请记住这一点。
发布于 2013-11-05 14:18:53
在所有浏览器中使图像的大小相同非常简单
CSS
body
{
height:100%;
width:100%;
}
.imageclass
{
height:15%; /* You can Change this according to you */
width:15%; /* You can Change this according to you */
}HTML
<img src="{% static "/static/img/left_arrow.png" %}" alt="prev" class="imageclass"/>这是因为对外部标记(div、span、body any)执行带有百分比的高度和宽度。例如,有一个div的高度是100,而跨度是50%,所以这就是为什么我把body和image分别作为%和%。
发布于 2016-01-05 16:27:03
添加"px“可能会解决你的问题。
<img src="{% static "/static/img/left_arrow.png" %}" alt="prev" height="15px" width="15px" />
https://stackoverflow.com/questions/19782063
复制相似问题