zoukankan      html  css  js  c++  java
  • 移动端rem适配

    1.index.html

     <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0,
        user-scalable=no">
    

    2.main.js

    // rem 适配
    var falses = true;
    //----------------------------------
    const setHtmlFontSize = () => {
      const htmlDom = document.getElementsByTagName('html')[0];
      let htmlWidth = document.documentElement.clientWidth || document.body.clientWidth;
      if (htmlWidth > 413 && htmlWidth<735) {
        htmlWidth = 414;
        console.log( htmlWidth);
        htmlDom.style.fontSize = `${htmlWidth / 16}px`;
      }
      //小米8适配
      if (htmlWidth == 393 ) {
        htmlWidth = 393;
        console.log( htmlWidth);
        htmlDom.style.fontSize = `${htmlWidth / 16}px`;
      }
    
      if (htmlWidth <= 375) {
        htmlWidth = 375;
        htmlDom.style.fontSize = `${htmlWidth / 16}px`;
      }
      if (htmlWidth > 1000) {
        falses =false
    
      }
    
    };
    if (falses){
    window.onresize = setHtmlFontSize;
    setHtmlFontSize();
    
    }
    

    3. 查看当期机型屏幕尺寸

                const screenWidth = document.body.clientWidth
                const screenHeight = document.body.clientHeight
                alert(`当前设备的屏幕尺寸(宽 x 高):${screenWidth} x ${screenHeight}`)
    

    4.手机查看vue项目

    vue.config.js

     devServer: {
            host: '111.11.11.11', // ip
            port: 8081, // 设置端口号
            https: false, // https:{type:Boolean}
            open: false, //配置自动启动浏览器
            proxy: null  //设置代理
        },
    
  • 相关阅读:
    LAMP的搭建
    linux利用命令重置大量密码
    CSS的应用下
    Day13 CSS的与应用
    Day12 CSS简单用法
    Day12 前端html
    Day11 数据库的基本语法(偏重于查询)
    Java-->把txt中的所有字符按照码表值排序
    Java-->将txt文件的所有行反转
    Java-->在txt文件每一行前加行数和冒号
  • 原文地址:https://www.cnblogs.com/ouyangkai/p/13686314.html
Copyright © 2011-2022 走看看