css之rem布局

rem介绍和原理网上都是,这里不具体介绍

以iphone6设计稿

let htmlWidth = document.documentElement.clientWidth || document.body.clientWidth;

let htmlDom = document.getElementsByTagName('html')[0];
htmlDom.style.fontSize  = htmlWidth / 10 + 'px';

  

  @function px2rem($px) {
        $fontSize: 37.5px;
        @return $px / $fontSize + rem;
    }
.box {
        width: px2rem(375px);
        height: px2rem(375px);
        background-color: green;
    }

flexible.js