我仅在iphone的标头上遇到z-index问题,并尝试了多种方法,并且还从此处https://stackoverflow.com/questions/37696746/ios-not-respecting-z-index-with-webkit-overflow-scrolling
获取了参考。当我们水平滚动时,我希望图标出现在阴影上方。
代码如下:
.masthead-nav-container {
position: relative;
background: #161D25;
}
.masthead-nav {
display: flex;
justify-content: space-between;
align-items: center;
overflow: auto;
-webkit-overflow-scrolling: touch;
scroll-behavior: smooth;
white-space: nowrap;
height: 52px;
border-top: 1px solid #535B63;
}
.masthead-nav-topics-item:last-child {
margin-right: 96px;
}
.masthead-nav-container::after {
background: linear-gradient(to right, rgba(22, 29, 37, 0), #161D25);
content: "";
position: absolute;
right: 0;
top: 1px;
bottom: 0;
height: 100%;
width: 96px;
z-index: 1;
}
.masthead-nav-topics {
margin-left: 16px;
line-height: 1;
}
.masthead-nav-topics-item {
display: inline-block;
margin-right: 24px;
}
.masthead-nav-topics-anchor {
font-size: 14px;
line-height: 20px;
text-transform: uppercase;
color: #fbfbfb;
}
.masthead-nav-social {
position: relative;
line-height: 1;
z-index: 5;
}
.masthead-nav-social-item {
display: inline-flex;
margin-left: 8px;
}
.masthead-nav-social-anchor {
width: 24px;
height: 24px;
background: #72DA38;
}
.masthead-nav-social-item:last-child {
margin-right: 16px;
}
<div class="masthead-nav-container js-nano-container">
<nav class="masthead-nav ">
<ul class="masthead-nav-topics">
<li class="masthead-nav-topics-item"><a class="masthead-nav-topics-anchor" href="#">Análisis</a></li>
<li class="masthead-nav-topics-item"><a class="masthead-nav-topics-anchor" href="#">Xataka Selección</a></li>
<li class="masthead-nav-topics-item"><a class="masthead-nav-topics-anchor" href="#">Móviles</a></li>
<li class="masthead-nav-topics-item"><a class="masthead-nav-topics-anchor" href="#">Inteligencia Artificial</a></li>
<li class="masthead-nav-topics-item"><a class="masthead-nav-topics-anchor" href="#">Asistentes de voz</a></li>
</ul>
<ul class="masthead-nav-social">
<li class="masthead-nav-social-item"><a href="#" class="masthead-nav-social-anchor masthead-social-flipboard" rel="nofollow"></a></li>
<li class="masthead-nav-social-item"><a href="#" class="masthead-nav-social-anchor masthead-social-instagram" rel="nofollow"></a></li>
<li class="masthead-nav-social-item"><a href="#" class="masthead-nav-social-anchor masthead-social-youtube" rel="nofollow"></a></li>
<li class="masthead-nav-social-item"><a href="#" class="masthead-nav-social-anchor masthead-social-twitter" rel="nofollow"></a></li>
</ul>
</nav>
</div>
注意:它仅出现在iphone和ipad Safari浏览器中