[英]How can I use scroll snap with container wrapped?
How can I use scroll-snap
property on the next code?:如何在下一个代码中使用
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>
I can just remove .wrapper
on this example code, but my actual code don't let me do that.我可以在此示例代码上删除
.wrapper
,但我的实际代码不允许我这样做。
is this what you're looking for?这是你要找的吗?
.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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.