相对于屏幕分辨率设置图像大小

相对于屏幕分辨率设置图像大小

本文介绍了相对于屏幕分辨率设置图像大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为自己建立一个网站..我想使用一个图像作为标题...我已经确保我的背景将缩放自己的任何屏幕分辨率...我如何确保图像(标题)也将根据屏幕分辨率缩放自己...

I am trying to build a website for myself.. I want to use an image as the header... I have made sure that my background will scale itself for any screen resolution... How do i make sure the image(header) will also scale it self according to the screen resolution...

例如:我的图像是350px int宽度和130px高度..我想这是屏幕分辨率为1280X768 ..的尺寸,应该根据屏幕尺寸按比例更改。

for example: my image is 350px int width and 130px in height.. i want this to be the size when screen resolution is 1280X768.. and should change proportionally based on screen size..

请告诉我如何做这最好使用CSS ..我也精确的js或jquery

Please tell me how to do this preferably using CSS.. i am also fine with js or jquery

提前感谢
Raj

Thanks in advanceRaj

推荐答案

如果您只指定css中的宽度,高度将自动缩放。

If you only specify the width in css, the height will scale automatically. You can easily specify the with of the image relative to its parent.

在您的示例中,您必须指定 width:27%(1280/350)。请注意,家长必须是100%宽。

In your example you would have to specify width: 27% (1280 / 350). Note that the parent will have to be 100% wide.

这篇关于相对于屏幕分辨率设置图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 22:09