zoukankan      html  css  js  c++  java
  • em和rem

    em是一个相对值,是相对于父元素的值。

    body{
        font-size:62.5%;/*10/16*100%=62.5%*/
    }
    h1{
        font-size:2.4em;/*2.4em*10=24px*/  
    }
    p{
        font-size:1.4em;/*1.4em*10=14px*/
    }
    li{
        font-size:1.4em;/*1.4*?=14px?*/
    }

    rem -- “font size of the root element”.  rem是相对于根元素<html>.

    html{font-size:62.5%;/*10/16*100%=62.5%*/}
    body{font-size:1.4rem;/*1.4*10px=14px*/}
    li{font-size:1.4rem;/*1.4*1.=14px*/}

     假设页面设计稿给我的时候是按照640宽度的标准尺寸给我的(html:10px),怎么去计算不同宽度下font-size的值?举个例子:380/640=0.6,380是640的0.6倍,所以384宽度的页面的font-size也等于它的0.6倍,这时3984的html的font-size就等于12px,在不同设备的宽度计算方式以此类推。

    html {
        font-size : 20px;
    }
    @media only screen and (min- 401px){
        html {
            font-size: 25px !important;
        }
    }
    @media only screen and (min- 428px){
        html {
            font-size: 26.75px !important;
        }
    }
    @media only screen and (min- 481px){
        html {
            font-size: 30px !important; 
        }
    }
    @media only screen and (min- 569px){
        html {
            font-size: 35px !important; 
        }
    }
    @media only screen and (min- 641px){
        html {
            font-size: 40px !important; 
        }
    }
  • 相关阅读:
    How do I change a .txt file to a .c file?
    [CQOI2007]余数求和
    CSP-J总结&题解
    【CSP游记S】
    [LuoguP1462]通往奥格瑞玛的道路
    归并排序——逆序对
    [NOIP 2011]选择客栈
    [二分图初步]【模板】二分图匹配,匈牙利算法
    [NOIP 2018]旅行
    黑魔法师之门 (magician)-并查集
  • 原文地址:https://www.cnblogs.com/wujiaqi/p/6081898.html
Copyright © 2011-2022 走看看