IOS端固定定位position:fixed失效问题(收藏)

 <body>
<!-- fixed定位的头部 -->
<div class="header">

</div>
<!-- 可以滚动的区域 -->
<div class="main">
    <div class="content"> 
    <!-- 内容区域 -->
    </div>
</div>
    <!-- fixed定位的底部 -->
    <footer class="footer">
        <input type="text" placeholder="请输入姓名">

    </footer>
 </body>

.header,.footer,.main{
        display: block;
    }
.header {
    position: fixed;
    top:0;
    left: 0;
    right:0;
    height:100px;
    }

.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right:0;
    height: 30px;
}
    .main{
        /*main绝对定位,进行内部滚动*/
        position: absolute;
        /*top是头部的高度*/
        top: 100px;  
        /*bottom是底部的高度*/
        bottom: 30px;
        /*使之可以滚动*/
        overflow-y: scroll;
        /*增加弹性滚动,解决滚动不流畅的问题*/
        -webkit-overflow-scrolling:touch;
    }
    .main .content{
    height:2000px;
    }

猜你喜欢

转载自blog.csdn.net/sally18/article/details/84324125