简体   繁体   English

根据浏览器调整大小(并保持尺寸)调整图像大小

[英]resize image based on browser resize (and keeping dimensions)

Google recently added backgrounds to it's home page .. Like it or hate it, it's got the ability to resize the background image while keeping the same proportions as the browser window resizes... Google最近在其首页中添加了背景。无论喜欢还是讨厌,它都能够调整背景图片的大小,同时保持与浏览器窗口调整大小相同的比例...

Anyone know of any jQuery to do that? 任何人都知道要执行此操作的jQuery吗?

宽度设置为百分比。

$(window).resize(function() {
   $('#imgContainer').width( $(this).width() );
                     .height( $(this).height() );
});

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

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