luckyXcc

var backgroundImgDiv = document.getElementById("backgroundImgDiv");
var img = backgroundImgDiv.getElementsByTagName("img")[0];

(setImgSize=function(){
var windowWidth = document.documentElement.clientWidth || document.body.clientWidth;
var windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
document.body.style.height = windowHeight + "px";
var cale = windowWidth/windowHeight;
if (cale >= 1920/1080) {
backgroundImgDiv.style.width = windowWidth+\'px\';
img.style.width = windowWidth+\'px\';

backgroundImgDiv.style.height = "auto";
img.style.height= "auto";
} else{
backgroundImgDiv.style.width = "auto";
img.style.width = "auto";

backgroundImgDiv.style.height = windowHeight+\'px\';
img.style.height= windowHeight+\'px\';
}
})();
window.onresize=setImgSize;

分类:

技术点:

相关文章:

  • 2022-01-04
  • 2021-11-02
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2021-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
  • 2022-12-23
  • 2021-09-25
  • 2022-12-23
  • 2022-01-13
相关资源
相似解决方案