h5 rem js

<script>
  !function(n){
    var e = n.document,
    t=e.documentElement,
    i=750,
    d=i/100,
    o="orientationchange"in n?"orientationchange":"resize",
    a=function(){
      var n=t.clientWidth||320;n>720&&(n=720);
      t.style.fontSize=n/d+"px"
    };
    e.addEventListener&&(n.addEventListener(o,a,!1),e.addEventListener("DOMContentLoaded",a,!1))
  }(window);
</ script>

to this code, placed html page, such as the total width of 750px design draft, a <div> element 600px wide, then css is: div {width: 6rem}

Guess you like

Origin www.cnblogs.com/adolfvicto/p/11388754.html