我正在尝试在应用中实现仅 CSS 的滚动捕捉行为,但发现 它在 iOS 中无法按预期工作。这里是 CodePen 的链接那个演示案例。
代码如下
body, html {
height: 100%;
margin: 0;
}
body {
display: flex;
justify-content: center;
align-items: center;
}
.panel-container {
width: 100%;
height: 50%;
border: 2px solid lightgray;
box-sizing: content-box;
display: flex;
overflow-x: scroll;
scroll-snap-type: x mandatory;
scroll-snap-type: mandatory;
scroll-snap-points-x: repeat(100%);
scroll-snap-destination: 0 0;
}
.panel {
scroll-snap-align: start;
border: 2px solid;
box-sizing: border-box;
min-width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.one {
border-color: red;
}
.two {
border-color: blue;
}
<div class="panel-container">
<div class="panel one">
One
</div>
<div class="panel two">
Two
</div>
</div>
容器需要 -webkit-overflow-scrolling: touch
和子 overflow:visible
(在你的情况下他们已经有了)。
关于ios - CSS 仅在 iOS 中滚动捕捉,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54677695/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |