【问题标题】:Fixed positioning/z-index issue in mobile safari修复了移动 Safari 中的定位/z-index 问题
【发布时间】:2013-08-18 18:00:54
【问题描述】:

所以有问题的网站:http://kaye.at/baby

下面的主要内容向上滚动到倒计时顶部和导航下方,它们都是固定元素。这在桌面上运行良好,但在移动 safari 上,当用户向上移动时,内容会在倒计时后滚动,但一旦释放触摸,它就会在前面弹出。

只是想知道这是一个错误还是可以修复的东西?

这是 CSS:

#header { position: fixed; width: 100%; top: 0px; z-index: 10; }
#content { width: 100%; position: relative; top: 650px; z-index: 7; }
#banner { position: fixed; width: 100%; position: fixed; background: url('http://kaye.at/baby/img/stork.jpg') no-repeat center bottom #fff;  padding-top: 185px; z-index: 1; }
#defaultCountdown { max-width: 70%; height: auto; }

和HTML(主要结构):

<div id="header">
    <div id="nav">
        <ul>
            <li><a class="active" href="index.php">START</a></li>
            <li><a href="ultrasound-images.php">ULTRASOUND PICS</a></li>
            <li><a href="pinkorblue.php">PINK OR BLUE?</a></li>
        </ul>
    </div>
</div>

<div id="banner">
   <div id="defaultCountdown"></div>
</div>

<div id="content">
</div>

【问题讨论】:

    标签: html css mobile safari fixed


    【解决方案1】:

    啊,太棒了。只需添加:

    -webkit-transform: translate3d(0,0,0);
    

    到#content div。

    【讨论】:

    • 对我不起作用,天哪,我将 translate3d(0,0,0) 添加到所有有意义的标签中
    【解决方案2】:

    如果您申请#banner {z-index:-1}body {background:transparent},您的问题应该会得到解决。

    【解决方案3】:

    对于 Mobile Safari,最好避免使用 position:fixed

    确保为滚动容器和其中的所有子容器使用此类 CSS

    .scrolling-container {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .scrolling-container .child-element {
        position: relative;
        -webkit-transform: translate3d(0,0,0);
    }
    

    【讨论】:

    • 谢谢你@Serge_Seletskyy
    • 它不能解决悬挂问题。重现步骤: 1)惯性滑下; 2)惯性向上滚动(有反弹); 3) 尝试向上滚动以反弹 - 在您尝试向下滚动之前,滚动视图完全挂起没有惯性。
    猜你喜欢
    • 1970-01-01
    • 2013-04-06
    • 2011-01-25
    • 2011-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多