zoukankan      html  css  js  c++  java
  • 大屏适配

    1.创建文件


    export const echartsSize = function (size, defalteWidth = 1920) {
    const docEl = document.documentElement
    const clientWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
    if (!clientWidth) return
    const fontSize = (clientWidth / defalteWidth)
    return Number((size * fontSize).toFixed(3))
    }

    // 设置系统缩放比,适配各分辨率
    export function refreshScale () {
    const baseWidth = document.documentElement.clientWidth
    const baseHeight = document.documentElement.clientHeight
    const appStyle = document.getElementById('app').style
    const bodyStyle = document.getElementsByTagName('body')[0].style
    const realRatio = baseWidth / baseHeight
    const designRatio = 16 / 9
    let scaleRate = baseWidth / 1920
    if (realRatio > designRatio) {
    scaleRate = baseHeight / 1080
    }

    /**/
    appStyle.transformOrigin = 'left top'
    appStyle.transform = `scale(${scaleRate})`
    appStyle.width = `${baseWidth / scaleRate}px`
    appStyle.height = `auto` //设置高度
    /*bodyStyle.background = `radial-gradient(#152B65, #122659 ,#030D32)`*/
    bodyStyle.background = `url('https://qiniu.dev.haiwojiamei.com/upload/meijia/20210728/cc9c326b15391925efa780367501f82e.png') no-repeat`
    bodyStyle.backgroundPosition ='center center'
    bodyStyle.backgroundSize = '100% 100%'
    }
    2.在文件中引入
    import {refreshScale} from '@/utils/util'
    3.初始化和窗口变化时执行
    mounted() {

    refreshScale();
    window.onresize=function(){
    refreshScale()
    }

    },

    3.设置
    body #app{
    1920px;
    height: 1080px;


    }





  • 相关阅读:
    MySQL性能优化(二):优化数据库的设计
    MySQL性能优化(一):优化方式
    PTA 07-图4 哈利·波特的考试 (25分)
    PTA 06-图3 六度空间 (30分)
    PTA 06-图2 Saving James Bond
    PTA 06-图1 列出连通集 (25分)
    PTA 05-树9 Huffman Codes (30分)
    PTA 05-树8 File Transfer (25分)
    PTA 05-树7 堆中的路径 (25分)
    PTA 04-树6 Complete Binary Search Tree (30分)
  • 原文地址:https://www.cnblogs.com/lixiaosong/p/15378412.html
Copyright © 2011-2022 走看看