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