我正在尝试实现一个类似我在这里看到的效果
但是每个部分的内容也应该是可滚动的,即只有在达到部分底部时才会固定。
例如,当内容为200vh时,像这样:
section {
position: sticky;
top: 0;
height: 200vh;
}
section img{
width:100%;
height:100%
}
section:nth-of-type(1) {
background: rgb(225, 204, 200);
}
section:nth-of-type(2) {
background: rgb(240, 216, 163);
}
section:nth-of-type(3) {
background: rgb(192, 211, 217);
}
正如你所看到的,第1和第2部分固定在顶部,我们无法滚动查看它们的照片。
但是最后一部分完美地工作。
那么我该如何实现这个效果?理想情况下使用纯CSS,但我也接受JavaScript解决方案。
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号