1. 程式人生 > >移動端rem適配 js程式碼

移動端rem適配 js程式碼

(function(){
    // rem適配
    var width = screen.width;
    var height = screen.height;
    // 以螢幕寬度750px為例  2/15*750 = 100 所以在螢幕寬度750px下1rem = 100px
    var fontSize = 2/15*width;
    document.documentElement.style.fontSize = fontSize + "px";
    var app = document.getElementById("app");
    app.style.height = height + "px";
})();