运行 ❯
获取您
自己
的网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> #container { scroll-snap-type: both mandatory; 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, in both x- and y-direction.</h3> <p>Use scroll wheel or drag the scrollbar inside the container box, let go, and see how the scroll-snap-type is in both directions.</p> <p>Try also to click on a box, then navigate through the boxes with the arrow keys.</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>