运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
转到 Spaces
<!DOCTYPE html> <html> <head> <style> #container { width: 40%; aspect-ratio: 2/3; margin: auto; border: solid black 2px; overflow-x: hidden; overflow-y: scroll; scroll-snap-type: y mandatory; white-space: nowrap; writing-mode: vertical-rl; scroll-padding-inline: 20px 0; } .blue { background-color: lightblue; width: 95%; aspect-ratio: 5/6; } .green { background-color: lightgreen; width: 80%; aspect-ratio: 3/4; } .blue, .green { display: inline-block; margin: 2px; scroll-snap-align: none start; } </style> </head> <body> <h3>CSS scroll-padding-inline 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 side to the top, and this also affects the scroll-padding-inline property.</p> <p>In this example, snap position is set to start in the inline direction, so the element in focus should snap into place with a 20px distance to the left of the container. But instead, because of the writing-mode value, the element in focus is offset by a 20px distance between child element and the top of the container.</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>