我需要在 Windows 调整大小时动态更改图像边距。但是当我调整窗口大小时,我需要刷新页面,以便将图像放在正确的位置。有没有办法不刷新页面来获得右边距。
var iw = $(window).width();
jQuery( document ).ready(function( $ ) {
updateContainer();
$(window).resize(function() {
updateContainer();
});
});
function updateContainer(){
$( ".rimg" ).each(function() {
var w =$(this).width();
if(w>iw){
marg = (w-iw);
$($(this)).css("margin-left", function() { return "-"+marg+"px" });
}
});
}