运行 ❯
获取您的
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> #container { scroll-snap-type: both proximity; width: 50%; margin: 30px auto; white-space: nowrap; aspect-ratio: 1/1; overflow-x: scroll; overflow-y: scroll; border: solid black 2px; } .green { background-color: lightgreen; } .pink { background-color: lightpink; } .blue { background-color: lightblue; } .yellow { background-color: yellow; } .grey { background-color: lightgray; } #container > div { display: inline-block; height: 80%; border-radius: 10%; aspect-ratio: 1/1; margin: 5px; scroll-snap-align: center; } </style> </head> <body> <h3>CSS scroll-snap-type property, with proximity value.</h3> <p>Proximity snap type value does not snap elements into place if scrolling position is right inbetween two snap points. Try scrolling so that you are right in between two elements, let go, and there should be no snapping.</p> <div id="container"> <div class="green"></div> <div class="pink"></div> <div class="yellow"></div> <div class="blue"></div> <div class="grey"></div> <div class="pink"></div> <br> <div class="pink"></div> <div class="blue"></div> <div class="grey"></div> <div class="yellow"></div> <div class="pink"></div> <div class="green"></div> <br> <div class="green"></div> <div class="pink"></div> <div class="yellow"></div> <div class="blue"></div> <div class="grey"></div> <div class="pink"></div> <br> <div class="pink"></div> <div class="yellow"></div> <div class="blue"></div> <div class="grey"></div> <div class="pink"></div> <div class="green"></div> <br> <div class="grey"></div> <div class="blue"></div> <div class="yellow"></div> <div class="pink"></div> <div class="green"></div> <div class="pink"></div> <br> <div class="green"></div> <div class="pink"></div> <div class="blue"></div> <div class="yellow"></div> <div class="pink"></div> <div class="grey"></div> </div> </body> </html>