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>

将此段代码,放置html页面,如设计稿总宽为750px,某<div>元素宽600px,那么css为:div{ width: 6rem }
posted @ 2019-08-21 14:53  adolfvicto  阅读(209)  评论(0编辑  收藏  举报