运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> #container { width: 80%; aspect-ratio: 2/1; margin: auto; border: solid black 2px; overflow-x: hidden; overflow-y: scroll; scroll-snap-type: y mandatory; } .blue { background-color: lightblue; width: 95%; aspect-ratio: 3/1; } .green { background-color: lightgreen; width: 80%; aspect-ratio: 4/1; } .blue, .green { margin: 2px; scroll-snap-align: start none; scroll-margin-inline-start: 20px; writing-mode: vertical-rl; } </style> </head> <body> <h3>CSS scroll-margin-inline-start property.</h3> <p>With the writing-mode property value set to vertical-rl the start of the element in the inline direction is changed from left to top, and this also affects the scroll-margin-inline-start property.</p> <p>In this example, snap position is set to start in block direction. To make a margin between child elements and container in this snap position, with writing-mode vertical-rl, the scroll-margin-inline-start property value is set to 20px.</p> <div id="container"> <div class="blue">Blue</div> <div class="green">Green</div> <div class="blue">Blue</div> <div class="green">Green</div> <div class="blue">Blue</div> <div class="green">Green</div> <div class="blue">Blue</div> </div> </body> </html>