运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> #container { position: relative; width: 60%; aspect-ratio: 2/3; margin: auto; border: solid black 2px; } #bottomDiv { position: absolute; bottom: 0; left: 0; width: 100%; height: 25px; z-index: 1; background-color: rgba(0, 0, 0, 0.8); color: white; } #imgDiv { position: absolute; inset: 0 0 0 0; overflow-x: hidden; overflow-y: scroll; scroll-snap-type: y mandatory; scroll-padding-block-end: 30px; } #imgDiv > img { width: 95%; margin: 2px; scroll-snap-align: end none; } </style> </head> <body> <h3>CSS scroll-padding-block-end property.</h3> <p>Drag the scrollbar vertically inside the photo gallery box, let go, and see the scroll-snap effect with snap position at the end of child elements in block direction, and scroll-padding-block-end set to 30px on the container. The effect of the scroll-padding-block-end property value is that the images are offset above the fixed bottom element.</p> <div id="container"> <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 id="bottomDiv">Fixed bottom element</div> </div> </body> </html>