请基于css、jquery帮我生成一个每页显示3张图片的自下向上无限滚动的效果
时间: 2024-05-14 22:13:36 浏览: 65
jQuery图片从下往上滚动效果
好的,您可以参考以下代码实现:
HTML代码:
```html
<div class="scroll-container">
<div class="scroll-wrapper">
<div class="scroll-item">
<img src="image1.jpg" alt="image 1">
</div>
<div class="scroll-item">
<img src="image2.jpg" alt="image 2">
</div>
<div class="scroll-item">
<img src="image3.jpg" alt="image 3">
</div>
<div class="scroll-item">
<img src="image4.jpg" alt="image 4">
</div>
<div class="scroll-item">
<img src="image5.jpg" alt="image 5">
</div>
<div class="scroll-item">
<img src="image6.jpg" alt="image 6">
</div>
</div>
</div>
```
CSS代码:
```css
.scroll-container {
height: 300px;
overflow-y: scroll;
overflow-x: hidden;
}
.scroll-wrapper {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.scroll-item {
width: calc(33.33% - 10px);
margin-bottom: 10px;
}
.scroll-item img {
width: 100%;
height: auto;
}
```
jQuery代码:
```js
$(document).ready(function() {
$('.scroll-container').scroll(function() {
if($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight) {
$(this).append($('.scroll-item').clone());
}
});
});
```
请注意,上述代码中的图片路径需要根据实际情况进行更改。
阅读全文