前端适配750px设计稿

全局引入

(function(doc, win) {
   
    const docEl = doc.documentElement,
        resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'
        const setFont = function() {
   
            let clientWidth = docEl.clientWidth;
            if (!clientWidth) return;
            if (clientWidth >= 750) {
   
                docEl.style.fontSize = '16px';
            } else {
   
                docEl.style.fontSize = 16 * (clientWidth / 750) + 'px';
            }
        };

    doc.addEventListener('DOMContentLoaded', setFont, false)
    win.addEventListener(resizeEvt, setFont, false)
    win.addEventListener('load', setFont, false)
})(document, window);

以1rem为16px为准设置html标签fontSize,蓝湖则设置如下图!搞定😊

在这里插入图片描述

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-09 18:10:02       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-09 18:10:02       106 阅读
  3. 在Django里面运行非项目文件

    2024-01-09 18:10:02       87 阅读
  4. Python语言-面向对象

    2024-01-09 18:10:02       96 阅读

热门阅读

  1. 探索中国顶级攻击面管理工具:关键优劣势解析

    2024-01-09 18:10:02       57 阅读
  2. Springboot自定义实体类读取nacos的当中的配置

    2024-01-09 18:10:02       56 阅读
  3. spring中的单例模式

    2024-01-09 18:10:02       79 阅读
  4. 使用ss代替netstat

    2024-01-09 18:10:02       59 阅读
  5. KY23 最小花费 DP

    2024-01-09 18:10:02       61 阅读
  6. 算法:删除字符串中的所有相邻重复项

    2024-01-09 18:10:02       66 阅读
  7. Redis面试题4

    2024-01-09 18:10:02       53 阅读