如何在下一段代码中使用scroll-snap属性?
.wrapper {
width: 100px;
height: 100px;
overflow: scroll;
}
.wrapper > div {
width: 300px;
height: 100px;
display: flex;
}
.item {
width: 100px;
height: 100px;
box-sizing: border-box;
border: black 1px dotted;
}<div class="wrapper">
<div>
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
</div>
</div>
我可以在这个示例代码中删除.wrapper,但实际代码不允许我这样做。
发布于 2022-08-30 08:01:48
这就是你要找的吗?
.wrapper {
width: 100px;
height: 100px;
overflow: scroll;
scroll-snap-type: x mandatory;
}
.wrapper > div {
width: 300px;
height: 100px;
display: flex;
}
.item {
width: 100px;
height: 100px;
box-sizing: border-box;
border: black 1px dotted;
scroll-snap-align: start;
}<div class="wrapper">
<div>
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
</div>
</div>
https://stackoverflow.com/questions/73538878
复制相似问题