移动端简单适配

// rem 单位换算:定为 75px 只是方便运算,750px-75px、640-64px、1080px-108px,如此类推
$vw_fontsize: 75; // iPhone 6尺寸的根元素大小基准值

@function rem($px) {
    @return ($px / $vw_fontsize) * 1rem;
}

// 根元素大小使用 vw 单位
$vw_design: 750;

html {
    font-size: ($vw_fontsize / $vw_design) * 100vw;
    // 同时,通过Media Queries 限制根元素最大最小值
    @media screen and (max-width: 280px) {
        font-size: 17.06667px
    }
    @media screen and (min-width: 540px) {
        font-size: 40px
    }
}
html,body{
    height: 100%;
}
// body 也增加最大最小宽度限制,避免默认100%宽度的 block 元素跟随 body 而过大过小
body {
    margin: 0 auto;
    width: 100%;
    max-width: 540px;
    min-width: 320px;
}
div,
p,
ul,
li,
h4,
h5,
h6,
input {
    margin: 0;
    padding: 0;
}

input:focus,
select:focus,
button:focus {
    outline: none;
}

body {
    padding-bottom: rem(80);
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: rem(28);
    line-height: rem(48);
    color: #000;
    background-color: #f5f5f5;
}

li {
    list-style: none;
}
/*使用*/
@import 'xxx.scss'; /*上面的文件*/
font-size: rem('测量的数字')
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值