简体   繁体   English

如何在包装容器的情况下使用滚动捕捉?

[英]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.

相关问题 如何使用包装文本的确切宽度而不是完整容器的宽度? - How can I use the exact width of wrapped text rather than that of the full container? 如何更改滚动捕捉距离? - How do I change scroll snap distance? 如何始终在纯 javascript 中编写 css scroll-snap-stop 代码? - How can I code a css scroll-snap-stop always in pure javascript? CSS:如何仅对锚标记应用滚动对齐对齐? - CSS: how can I apply scroll-snap-align only for anchor tags? 使用滚动捕捉时,如何将默认位置设置为第一列或第一行以外的位置? - When using scroll snap, how can I set the default position to something other than the first column or row? scroll-snap-type 不起作用,我该如何解决? - scroll-snap-type doesn't work, How can I fix it? 如何使用 CSS 滚动捕捉与 Javascript 鼠标滚轮? - How to use CSS scroll-snap with Javascript mouse wheel? 如何进行显示:flex容器水平展开并包裹内容? - How can I make a display:flex container expand horizontally with its wrapped contents? CSS快照滚动:如何在div中间引发快照滚动? - CSS snap scroll: How do I induce the snap scrolling in the middle of a div? 我不能在表格中使用垂直滚动,而在该表格所在的容器中使用水平滚动 - I can't use Vertical Scroll in a table and Horizontal Scroll in a container this table is in
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM