简体   繁体   English

自动调整元素的高度

[英]Auto resize height of element

I want to create a banner like this http://www.firstborn.com/ 我想创建一个像这样的横幅http://www.firstborn.com/

I have got 3 different images loading in at different resolutions but the part i am struggling with it finding JQuery to replicate the sizing. 我已经以不同的分辨率加载了3张不同的图像,但是我在寻找JQuery来复制尺寸设置的过程中遇到了困难。

This banners height reduces with the screen size so if you just drag your browser viewport smaller you will see what i mean. 此横幅的高度随着屏幕尺寸的减小而减小,因此,如果您将浏览器视口拖动得更小,您将明白我的意思。

i want to set the height initially for 3 or 4 set sizes then have the height reduce or enlarge depending on the screen. 我想先为3或4种设置大小设置高度,然后根据屏幕的不同减小或增大高度。

Ideally the solution needs to be as widely supported as possible :) 理想情况下,该解决方案需要得到尽可能广泛的支持:)

Any help would be really appreciated. 任何帮助将非常感激。

Set following css properties to your element: 将以下CSS属性设置为您的元素:

position:absolute;
height:auto;

That's it. 而已。 Let me know if you are still then facing any problem..!!! 让我知道您是否仍然遇到任何问题.. !!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM