移动端rem布局与高清屏幕适配

博客介绍了移动端视口在未设置时为980,提及逻辑像素和物理像素,还阐述了meta标签的相关内容,给出移动端1px解决方案,同时说明flexible.js会自行生成meta标签,无需手动编写。
  1. 移动端视口在没设置情况下是980
document.documentElement.clientWidth
window.screen
复制代码
  1. 逻辑像素和物理像素
拿iphone4为例,横向逻辑像素为320个,横向物理像素有640个,所以window.devicePixelRatio = 2, 就是2倍屏
复制代码
  1. meta标签
  <meta name="viewport" content="width=device-width, initial-scale=1.0,
  maximum-scale=1.0, user-scalable=no">
复制代码
  1. 移动端1px 解决方案
.radius-border{
    position: relative;
}
@media screen and (-webkit-min-device-pixel-ratio: 2){
    .radius-border:before{
        content: "";
        pointer-events: none; /* 防止点击触发 */
        box-sizing: border-box;
        position: absolute;
        width: 200%;
        height: 200%;
        left: 0;
        top: 0;
        border-radius: 8px;
        border:1px solid #999;
        -webkit-transform(scale(0.5));
        -webkit-transform-origin: 0 0;
        transform(scale(0.5));
        transform-origin: 0 0;
    }
}
复制代码
  1. flexible.js不要写meta标签,自己会生成
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值