css3 - 页面布局问题
黄舟
黄舟 2017-04-17 11:43:42
0
6
476

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

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(6)
大家讲道理

position:fixed;

伊谢尔伦

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

Peter_Zhu

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

左手右手慢动作

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.

黄舟

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>
阿神

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template