zoukankan      html  css  js  c++  java
  • 自适应背景图,不变形,不留空白

    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;

  • 相关阅读:
    最大流问题的几种经典解法综述
    有上下界的网络流
    hiho一下
    poj 1018
    状压dp
    hdu 1043
    Poj1015
    7.14
    sgu 128
    (zhuan)
  • 原文地址:https://www.cnblogs.com/luckyXcc/p/5946492.html
Copyright © 2011-2022 走看看