在设置图像的高度和宽度之后保持Aspact比率的任何方法 [英] Any way for maintain Aspact Ratio after Set hight and width of an image

查看:148
本文介绍了在设置图像的高度和宽度之后保持Aspact比率的任何方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大小的图像:

高度:100px,宽度1000px,





我在我的主页上使用那个图像,我在那里修复了高度和宽度:50px,



所以它看起来像抓图像,



我能做什么,



图片在我的情况下是否可以保持相同的空间比例,



当complusery高度和图像修复时

解决方案

当您使用<$显示图像时c $ c>< img> 元素,不要指定宽度高度属性。仅指定其中一个或不指定。如果您指定none,它将显示源图像的精确像素大小(当然,在100%浏览器缩放中);如果您指定 width height ,而不是两者,浏览器会自动选择省略的大小,并且正确从图像元数据中找到的宽高比。



选择哪一个,取决于网站设计。例如,如果您在水平行中显示图像,则相同的高度可能是优先级。在所有情况下,更喜欢原始尺寸或接近原始尺寸:通过相当大的因素重新采样图像会使质量变得难看,特别是如果你去高档。尽量避免它。



就这么简单。



-SA

i have a image of size:
Height:100px,and width 1000px,


and i use that image at my home page where i fix the height And width both :50px,

So it looks like Scratching Image,

so what can i do,

it is possible or not that image maintain same aspacet ration in my condition,

when it is complusery that height and with of image are fix

解决方案

When you show an image using the <img> element, don''t specify both width and height attributes. Specify only one of them or none. If you specify none, it will show exact pixel size of the source image (in 100% browser zoom, of course); if you specify either width or height, not both, the omitted size will be chosen by the browser automatically, with correct aspect ratio found from the image metadata.

Which one to select, depends on the site design. For example, if you show images in a horizontal row, same height could be a priority. In all cases, prefer original size or close to it: re-sampling the image by a considerable factors make the quality ugly, especially if you go upscale. Try to avoid it by all means.

As simple as that.

—SA


这篇关于在设置图像的高度和宽度之后保持Aspact比率的任何方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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