如何以像素为单位指定图像大小 [英] how to specify image size in pixels

查看:108
本文介绍了如何以像素为单位指定图像大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以像素为单位指定图片大小的快速问题:

Quick question about specifying the size of images in pixels:

<img src="/logo.jpg" alt="logo" width="200px" height="120px" />

<img src="/logo.jpg" alt="logo" width="200" height="120" />

我一直在投入px,但最近注意到很少有人这样做。我最好离开这个吗?这是否与其中一种方式有关?

I've been always putting in the px but recently noticed that very few people do this. Am I better off leaving that out? Does it matter one way or the other?

推荐答案

据我所知,您不会添加 px label标签到 img 标签本身的宽度/高度属性值,我相信(虽然可能是错误的),这是因为像素使用不管。然而,在CSS中,可以使用不同的单位来指定宽度和高度,因此在使用CSS时添加标签是适当的。

As far as I know, you do not add the px label to width/height attribute values on the img tag itself, and I believe (though could be wrong) it's because pixels are used regardless. In CSS, however, one may use different units to specify width and height, therefore it is appropriate to add the label when using CSS.

这篇关于如何以像素为单位指定图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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