在HTML中设置图像尺寸 [英] Setting image dimensions in HTML

查看:121
本文介绍了在HTML中设置图像尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设置图像的尺寸(在静态内容中)是一个很好的做法,即使我已经将图像裁剪到正确的尺寸,并且它的容器有固定的尺寸和溢出:hidden?

 < img src =title =alt =width =100height =100/> 


解决方案

通常,您应该提供高度和宽度标签,浏览器可以为图像保留needes空间。否则,在加载页面的过程中布局可能会发生变化。

因为你有一个固定大小的容器和溢出:隐藏,它可能不会有太大的帮助。但即使它没有帮助,也没有害处。所以你应该坚持始终添加高度和宽度属性。



http://www.w3schools.com/tags/att_img_width.asp (请参阅定义和用法下的提示)


Is it good practice to set the dimensions of an image (in static content), even if I have cropped the image to the correct size and it's container has fixed dimensions and overflow:hidden ?

<img src="" title ="" alt="" width="100" height="100"/>

解决方案

Generally you should provide the height and width tags, so that the browser can reserve the needes space for the image. Else, the layout may change during the loading of the page.

As you have a fixed size container and overflow: hidden, it probably won't help much though. But even if it doesn't help, it does no harm either. So you should stick with always adding height and width attributes.

http://www.w3schools.com/tags/att_img_width.asp (See the tips under "Definition and Usage")

这篇关于在HTML中设置图像尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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