zoukankan      html  css  js  c++  java
  • 可伸缩布局方案flex

    /**可伸缩布局方案
     * rem计算方式:设计图尺寸px / 100 = 实际rem  例: 100px = 1rem
     */
    !function (window) {

        /* 设计图文档宽度 */
        var docWidth = 1920;

        var doc = window.document,
            docEl = doc.documentElement,
            resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize';

        var recalc = (function refreshRem () {
            var clientWidth = docEl.getBoundingClientRect().width;

            docEl.style.fontSize = Math.max(Math.min(20 * (clientWidth / docWidth), 30), 8.55) * 5 + 'px';

            return refreshRem;
        })();

        /* 添加倍屏标识,安卓倍屏为1 */
        docEl.setAttribute('data-dpr', window.navigator.appVersion.match(/iphone/gi) ? window.devicePixelRatio : 1);

        if (/iP(hone|od|ad)/.test(window.navigator.userAgent)) {
            /* 添加IOS标识 */
            doc.documentElement.classList.add('ios');
            /* IOS8以上给html添加hairline样式,以便特殊处理 */
            if (parseInt(window.navigator.appVersion.match(/OS (d+)_(d+)_?(d+)?/)[1], 10) >= 8)
                doc.documentElement.classList.add('hairline');
        }

        if (!doc.addEventListener) return;
        window.addEventListener(resizeEvt, recalc, false);
        doc.addEventListener('DOMContentLoaded', recalc, false);

    }(window);

  • 相关阅读:
    hdu 3613 Best Reward 扩展kmp
    hdu 4333 Revolving Digits 扩展kmp
    poj 1904 King's Quest 强连通
    hdu 3068 最长回文 manacher
    Codeforces Round #243 (Div. 2) C. Sereja and Swaps
    poj 3680 Intervals 费用流
    两个kmp hdu 2594 & hdu 2087
    hdu 3336 count the string
    Arcgis安装要素
    JS关闭窗口而不提示
  • 原文地址:https://www.cnblogs.com/hlyin/p/9359801.html
Copyright © 2011-2022 走看看