兼容IOS android 页面滑动的CSS设置

 

<style type="text/css">
#scroller {
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
    position: absolute;
    width: 100%;
    top: 0px;
    bottom: 0px;
    right: 0px;
    left: 0px;
}

@media all and (-webkit-transform-3d) {
    #scroller {
        overflow-y: scroll;
        overflow-x: hidden;
    }
}
</style>

2019.3.19更新:

昨晚突然被问iOS和Android navigation的适配方案。(因为iOS的webview上面有一个navigation bar,导致可视范围有一点偏差。)还好我之前写过这篇博客,代码留了下来了。回家后自己开了电脑,试了一下是可以的。这里贴上代码。

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>YESHEN</title>
    <style type="text/css">
    body {
        margin: 0px;
    }

    #title {
        height: 50px;
        background-color: blue;
        line-height: 50px;
        font-size: 30px;
        color: white;
    }

    #scroller {
        box-sizing: border-box;
        -webkit-overflow-scrolling: touch;
        position: absolute;
        width: 100%;
        top: 50px;
        bottom: 0px;
        right: 0px;
        left: 0px;
    }

    @media all and (-webkit-transform-3d) {
        #scroller {
            overflow-y: scroll;
            overflow-x: hidden;
        }
    }
    </style>
</head>

<body>
    <div id="title">
        2019
    </div>
    <div id="scroller">
        <br/>.<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>.<br/>
    </div>
</body>
</html>

 

预览效果大概是这样的

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值