zoukankan      html  css  js  c++  java
  • 原生js设置rem

    使用rem是为了界面响应不同尺寸的手机,引入下面的方法就可以使用rem了。

     setFontSize: function (doc, win) {
        var docEl = doc.documentElement
        var resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'
        var reCaculate = function () {
        var clientWidth = docEl.clientWidth
        if (!clientWidth) return
          docEl.style.fontSize = 100 * (clientWidth / 750) + 'px'
        }
        if (!doc.addEventListener) return
        win.addEventListener(resizeEvt, reCaculate, false)
        doc.addEventListener('DOMContentLoaded', reCaculate, false)
      },

    使用这个方法的代码:

    this.setFontSize(document, window)
    

      

  • 相关阅读:
    2015多校.Zero Escape (dp减枝 && 滚动数组)
    UVa-11809
    UVa-1588 Kickdown
    UVa-1587
    UVa-10340
    UVa-202
    UVa-1368
    UVa-232 Crossword Answers
    UVa-227
    UVa-455 Periodic Strings
  • 原文地址:https://www.cnblogs.com/cczlovexw/p/8856833.html
Copyright © 2011-2022 走看看