skyBlue0077

关于前端 px 自动转 rem(不在工程化项目中)

  •  
  •   skyBlue0077 · Apr 28, 2020 via Android · 2292 views
    This topic created in 2205 days ago, the information mentioned may be changed or developed.

    单纯的 html 中,如何根据 html 设置的字体大小去实现一个类似 pxtorem 的功能?3

    6 replies    2020-04-28 14:38:29 +08:00
    looking0truth
        1
    looking0truth  
       Apr 28, 2020
    不在编译的时候做基本不太可能吧
    能想到的也就像淘宝首页 scale 直接做缩放
    whypool
        2
    whypool  
       Apr 28, 2020
    vw 一把梭就没 rem 啥事了
    skyBlue0077
        3
    skyBlue0077  
    OP
       Apr 28, 2020
    @looking0truth 嗯,感觉也不太可能,我直接用蓝湖把单位转成 rem,不纠结了。
    rain0002009
        4
    rain0002009  
       Apr 28, 2020
    document.documentElement.style.fontSize = ( innerWidth*20/320 ) + 'px'

    然后自己拿计算器算?
    px*320/designWidth/20 + 'rem'
    SilentDepth
        5
    SilentDepth  
       Apr 28, 2020
    vw 支持度那么好,何苦逼自己继续算 rem 呢
    red2dog
        6
    red2dog  
       Apr 28, 2020 via iPhone
    vscode 插件
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   993 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 21:55 · PVG 05:55 · LAX 14:55 · JFK 17:55
    ♥ Do have faith in what you're doing.