运行 ❯
获取您的
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 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; } #container > img { height: 95%; margin: 2px; scroll-snap-align: start; scroll-margin-left: 30px; } </style> </head> <body> <h3>CSS scroll-margin-left property.</h3> <p>Drag the scrollbar horizontally inside the photo gallery box, let go, and see the scroll-snap effect with snap position start and scroll-margin-left 30px.</p> <div id="container"> <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> </body> </html>