search

Home  >  Q&A  >  body text

css3 - 页面布局问题

在手机APP端如何设置头和尾不变,当滑动中间的内容时头和尾不会随着滑动

黄舟黄舟2778 days ago457

reply all(6)I'll reply

  • 大家讲道理

    大家讲道理2017-04-17 11:45:42

    position:fixed;

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 11:45:42

    In addition to position:fixed, don’t forget to add padding-top and padding-bottom to the body to eliminate the abnormal display problem of content caused by fixed

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 11:45:42

    position:sticky
    sticky polyfill: https://github.com/wilddeer/s...

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 11:45:42

    Use position:fixed to solve it, and then add padding-top and padding-bottom styles to the body. Otherwise, part of the middle content will be covered by the head and tail.

    reply
    0
  • 黄舟

    黄舟2017-04-17 11:45:42

    position:fixed can solve the problem, but bugs will appear under Android. The perfect solution should be to avoid fixed

    
    <!DOCTYPE html>
    <html>
    <head>
        <title>布局</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="viewport" content="initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0" />
        <style type="text/css">
            *{margin:0;padding:0;font-size: 2vw;color: #fff;}
            .top{
                height: 50px;
                background: #f00;
                position: relative;
            }
            .mean{
                height: auto;
                background: #095fb6;
                position: absolute;
                top: 50px;
                bottom:50px;
                left: 0;
                right: 0;
                overflow-x: hidden;
                overflow-y: auto;
            }
            .bottom{
                height: 50px;
                background: #ccc;
                position: absolute;
                bottom: 0px;
                left: 0px;
                right: 0px;
            }
        </style>
    </head>
    <body>
        <p class="top">我是文字</p>
        <p class="mean">
                <p><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><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><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><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><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><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>0000</p>
        </p>
        <p class="bottom">我是文字</p>
    </body>
    </html>

    reply
    0
  • 阿神

    阿神2017-04-17 11:45:42

    Everyone said it was very good and perfect. I came here to learn haha

    reply
    0
  • Cancelreply