safari浏览器阻止用户缩放和定位样式失效

(1)阻止用户缩放

        <meta http-equiv="X-UA-Compatible" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">

(2)定位样式失效

首先将需要滚动的内容放在一个容器里面,定位的元素相对他们父元素定位

<body class="layout-fixed">
    <!-- fixed定位的头部 -->
    <header>
        
    </header>
    
    <!-- 可以滚动的区域 -->
    <main>
        <!-- 内容在这里... -->
    </main>
    
    <!-- fixed定位的底部 -->
    <footer>
        <input type="text" placeholder="Footer..."/>
        <button class="submit">提交</button>
    </footer>
</body>

  样式入下:

header, footer, main {
    display: block;
}

header {
    position: fixed;
    height: 50px;
    left: 0;
    right: 0;
    top: 0;
}

footer {
    position: fixed;
    height: 34px;
    left: 0;
    right: 0;
    bottom: 0;
}

main {
    margin-top: 50px;
    margin-bottom: 34px;
    height: 2000px
}

  

 

posted @ 2021-02-20 14:15  鸡腿太小  阅读(172)  评论(0编辑  收藏  举报