我不知道我在这里做错了什么,但我的nav在safari上并不坚持在购物车的顶部,有时它在其他浏览器上也不工作,我真的不明白是怎么回事。我试过定位导航,但没有一个是无效的。希望有人能帮助我理解这里的问题。提前道谢。
<div class="cart">
<nav>
...
</nav>
</div>
.cart {
position: fixed;
overflow-y: scroll;
z-index: 10;
width: 100%;
height: 100%;
right: 0;
top: 0;
transform: translateX(100%);
background-color: white;
color: #ffff;
transition: 0.3s;
}
nav {
font-family: abeja;
position: sticky;
position: -webkit-sticky;
z-index: 11;
top: 0;
left: 0;
width: 100%;
padding: 20px;
display: flex;
background-color: #fff;
color: gray;
align-items: center;
justify-content: space-between;
box-shadow: 0 1px 13px 0 rgb(230, 230, 230);
}
像这样试试
position: sticky;
position: -webkit-sticky;
只需添加位置:-webkit-sticky;