运行 ❯
获取您
自己
的网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> #container { position: relative; width: 60%; aspect-ratio: 3/2; margin: auto; border: solid black 2px; } #leftDiv { position: absolute; top: 0; right: 0; height: 100%; width: 25px; z-index: 1; background-color: rgba(0, 0, 0, 0.8); color: white; writing-mode: vertical-lr; text-orientation: upright; } #imgDiv { position: absolute; inset: 0 0 0 0; padding-right: 40px; overflow-x: scroll; overflow-y: hidden; scroll-snap-type: x mandatory; white-space: nowrap; scroll-padding-right: 30px; } #imgDiv > img { height: 95%; margin: 2px; scroll-snap-align: none end; } </style> </head> <body> <h3>CSS scroll-padding-right property.</h3> <p>Scroll inside the photo gallery box, stop scrolling, and see the scroll-snap effect with snap position end and scroll-padding-right 30px. The effect of the scroll-padding-right property value is that the images comes out from behind the fixed element on the right.</p> <div id="container"> <div id="leftDiv">Fixed</div> <div id="imgDiv"> <img src="img_chania.jpg" alt="alley" width="460" height="345"> <img src="img_forest_narrow.jpg" alt="bridge in jungle" width="326" height="400"> <img src="img_mountains.jpg" alt="mountains" width="600" height="400"> <img src="img_man_narrow.jpg" alt="man with camera" width="709" height="963"> <img src="img_5terre.jpg" alt="Cinque Terre" width="600" height="400"> </div> </div> </body> </html>