运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
转到 Spaces
<!DOCTYPE html> <html> <head> <style> #container { width: 80%; aspect-ratio: 5/2; margin: auto; border: solid black 2px; overflow-x: hidden; overflow-y: scroll; scroll-snap-type: y mandatory; } .blue { background-color: lightblue; height: 65%; aspect-ratio: 5/2; } .green { background-color: lightgreen; height: 50%; aspect-ratio: 9/2; } .blue, .green { display: block; margin: 5px; scroll-snap-align: start none; } </style> </head> <body> <h3>CSS scroll-snap-align property, vertical scroll.</h3> <p>Use scroll wheel or drag the scrollbar vertically inside the container box, let go, and see the scroll-snap-align start effect.</p> <p>Click on a box, then navigate through the blue and green boxes with the up and down arrow keys.</p> <div id="container"> <div class="blue"></div> <div class="green"></div> <div class="blue"></div> <div class="green"></div> <div class="blue"></div> <div class="green"></div> <div class="blue"></div> <div class="green"></div> <div class="blue"></div> <div class="green"></div> <div class="blue"></div> <div class="green"></div> <div class="blue"></div> </div> </body> </html>