如何使用css指定图像尺寸?

时间:2022-05-30 07:27:36

I have a result of 93% pagespeed and 88% yslow on gtmetrix, but 70% on this "Specify image dimensions". what should I do?

我在gtmetrix上有93%的pagespeed和88%的yslow,但在“指定图像尺寸”上有70%的结果。我该怎么办?

The following image(s) are missing width and/or height attributes.

http://www.cochlea.co.il/wp-content/uploads/2015/06/ab_trans.png (Dimensions: 25 x 25)
http://www.cochlea.co.il/wp-content/uploads/2015/06/cochlear_trans.png (Dimensions: 25 x 25)
http://www.cochlea.co.il/wp-content/uploads/2015/06/medel_trans.png (Dimensions: 25 x 25)
http://www.cochlea.co.il/wp-content/uploads/2015/07/cochleagold.png (Dimensions: 316 x 158)
http://www.cochlea.co.il/wp-content/uploads/2015/07/gmaps-25.png (Dimensions: 25 x 25)
http://www.cochlea.co.il/wp-content/uploads/2015/07/ta.png (Dimensions: 35 x 35)

<img src="/wp-content/uploads/2015/06/ab_trans.png" alt="AB">

1 个解决方案

#1


2  

In your HTML, make sure you specify dimensions for your images.

在HTML中,请确保指定图片的尺寸。

Correct:

<img src="http://www.cochlea.co.il/wp-content/uploads/2015/06/ab_trans.png" width="25" height="25" />

Incorrect (not strictly incorrect per say, but definitely less efficient - this is what pagespeed/yslow are complaining about):

不正确(不是说严格不正确,但效率肯定不高 - 这就是pagespeed / yslow所抱怨的):

<img src="http://www.cochlea.co.il/wp-content/uploads/2015/06/ab_trans.png" />

#1


2  

In your HTML, make sure you specify dimensions for your images.

在HTML中,请确保指定图片的尺寸。

Correct:

<img src="http://www.cochlea.co.il/wp-content/uploads/2015/06/ab_trans.png" width="25" height="25" />

Incorrect (not strictly incorrect per say, but definitely less efficient - this is what pagespeed/yslow are complaining about):

不正确(不是说严格不正确,但效率肯定不高 - 这就是pagespeed / yslow所抱怨的):

<img src="http://www.cochlea.co.il/wp-content/uploads/2015/06/ab_trans.png" />