在移动游猎中固定定位/ z指数问题

use*_*984 31 html css safari mobile fixed

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

下面的主要内容向上滚动倒计时的顶部和导航下的固定元素.这在桌面上工作正常,但在移动游戏中,当用户向上移动时内容滚动倒计时,但一旦触摸释放,它就会弹出.

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

这是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; }
Run Code Online (Sandbox Code Playgroud)

和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>
Run Code Online (Sandbox Code Playgroud)

use*_*984 65

太棒了.只需添加:

-webkit-transform: translate3d(0,0,0);
Run Code Online (Sandbox Code Playgroud)

到#content div.


Ser*_*kyy 5

对于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);
}
Run Code Online (Sandbox Code Playgroud)