Javascript 窗户。DispathEvent重新调整大小问题?

Javascript 窗户。DispathEvent重新调整大小问题?,javascript,jquery,css,resize,Javascript,Jquery,Css,Resize,在窗口resize()触发时,它必须使用“#snapContainer”div(我的意思是背景css属性) $('#snapContainer').css({"background-size": "95%", "min-height": "100%", "position": "relative", "left": "2%", "margin-bottom": "15%", "display": "inline-block"}); $('.'+snapCloseClass).show(); //

在窗口
resize()
触发时,它必须使用“
#snapContainer
div(我的意思是
背景css
属性)

$('#snapContainer').css({"background-size": "95%",
"min-height": "100%",
"position": "relative",
"left": "2%",
"margin-bottom": "15%",
"display": "inline-block"});
$('.'+snapCloseClass).show();
//window.dispatchEvent(new Event('resize'));
$(window).resize(function() {
  $('#snapContainer').css({"background-size": "95%",
  "min-height": "100%",
  "position": "relative",
  "left": "2%",
  "margin-bottom": "15%",
  "display": "inline-block"});
});
我的jquery代码是

$('#snapContainer').css({"background-size": "95%",
"min-height": "100%",
"position": "relative",
"left": "2%",
"margin-bottom": "15%",
"display": "inline-block"});
$('.'+snapCloseClass).show();
//window.dispatchEvent(new Event('resize'));
$(window).resize(function() {
  $('#snapContainer').css({"background-size": "95%",
  "min-height": "100%",
  "position": "relative",
  "left": "2%",
  "margin-bottom": "15%",
  "display": "inline-block"});
});

能否更新您面临的问题?$(窗口)。resize(函数())应根据div值调整大小。在此上下文中,div=#snapContainer值。但现在,窗口将根据设备宽度*高度值进行更改。能否更新您面临的问题?$(窗口)。resize(函数(),应根据div值调整大小。在此上下文中,div=#snapContainer值。但现在,窗口将根据设备宽度*高度值进行更改。