使用CSS调整图片大小,或使用< img>标签? [英] Is it better/faster to resize an image with CSS, or with the <img> tag?

查看:211
本文介绍了使用CSS调整图片大小,或使用< img>标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道什么是更好/更快的方式来调整图像大小。

I was wondering what is the better/faster way to resize an image.

通常我会调整CSS的图像大小,但一个学院告诉我, width 属性,例如

Normally I would resize an image with CSS, but a college told me that by using the width attribute, e.g.

<img width="size" [..]> 

浏览器会使网页更快。

任何人都知道这是否真的吗?

Anyone know if this is true?

推荐答案

width img es和对象的情况下,code> height 。他们提供图像的元数据,所以它是完全精细IMO依赖这些属性为了告诉用户代理它应该预先将元素X维度在图像完全渲染之前。

width and height are semantic in the case of imges and objects. They provide metadata for images so it is completely fine IMO to rely on those attributes in order to tell the user agent that it should presize the element to X dimensions prior to the image fully rendering.

这篇关于使用CSS调整图片大小,或使用&lt; img&gt;标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆