Bootstrap 轮播图片未显示
Bootstrap carousel Images not showing
我正在使用延迟加载的旋转木马,这样图像只在滚动时加载,
但问题是除了轮播内的图像之外的所有图像都没有加载。
我也试过 this 解决方案。
轮播
<div class="owl-carousel">
<div class="item">
<a href="/descriptive-essay-writer"><img src="/_/img/Descriptive-Essay.jpg" class="lazy" alt="Descriptive Essay"></a>
<a href="/descriptive-essay-writer"><h4>Descriptive Essay</h4></a>
<p>Our experienced descriptive essay writers paint a beautiful picture through words and give you an amazing descriptive essay.</p>
</div>
<div class="item">
<a href="/persuasive-essay-writer"><img src="/_/img/Persuasive-Essay.jpg" class="lazy" alt="Persuasive Essay"></a>
<a href="/persuasive-essay-writer"><h4>Persuasive Essay</h4></a>
<p>Our persuasive essay writers are brilliant at convincing the reader and keeping them engaged in the essay from start to finish.</p>
</div>
<div class="item">
<a href="/expository-essay-writer"><img src="/_/img/Expository-Essay.jpg" class="lazy" alt="Expository Essay"></a>
<a href="/expository-essay-writer"><h4>Expository Essay</h4></a>
<p>Our expository essay writing service delivers a perfect expository essay complete with definitions, facts, examples and stats.</p>
</div>
<div class="item">
<a href="/narrative-essay-writer"><img src="/_/img/Narrative-Essay.jpg" class="lazy" alt="Narrative Essay"></a>
<a href="/narrative-essay-writer"><h4>Narrative Essay</h4></a>
<p>Our narrative essay writers are master in the art of story-telling and making your essays engaging so you can get the best grade.</p>
</div>
</div>
脚本
<script>
$('.owl-carousel').owlCarousel({
loop:true,
margin:10,
responsiveClass:true,
autoplay:true,
autoplayTimeout:2000,
rewindSpeed : 1000,
responsive:{
0:{
items:1,
nav:true
},
600:{
items:2,
nav:false
},
1000:{
items:3,
nav:true,
}
}
})
</script>
延迟加载
<script>
$(function() {
$('.lazy').lazy({
beforeLoad: function(element){
console.log('image "' +element.data('src')+ '" is about to be loaded');
},
afterLoad: function(element) {
console.log('image "' +element.data('src') + '" was loaded successfully');
},
onError: function(element) {
console.log('error');
},
onFinishedAll: function() {
console.log('lazy instance is about to be destroyed')
}
});
});
</script>
请帮助我做错了什么,我也尝试过更改脚本的顺序但是没有 luck.My 网站是活的 here
这只是一个小问题。请为 .owl-item
添加以下代码。
.owl-item {
display: inline-block;
}
将此添加到 owl 项
.owl-item {
display: inline-block;
}
还有一期:
我假设 div 之外的内容应该被隐藏
.owl-carousel{
overflow:hidden;
}
我正在使用延迟加载的旋转木马,这样图像只在滚动时加载, 但问题是除了轮播内的图像之外的所有图像都没有加载。 我也试过 this 解决方案。
轮播
<div class="owl-carousel">
<div class="item">
<a href="/descriptive-essay-writer"><img src="/_/img/Descriptive-Essay.jpg" class="lazy" alt="Descriptive Essay"></a>
<a href="/descriptive-essay-writer"><h4>Descriptive Essay</h4></a>
<p>Our experienced descriptive essay writers paint a beautiful picture through words and give you an amazing descriptive essay.</p>
</div>
<div class="item">
<a href="/persuasive-essay-writer"><img src="/_/img/Persuasive-Essay.jpg" class="lazy" alt="Persuasive Essay"></a>
<a href="/persuasive-essay-writer"><h4>Persuasive Essay</h4></a>
<p>Our persuasive essay writers are brilliant at convincing the reader and keeping them engaged in the essay from start to finish.</p>
</div>
<div class="item">
<a href="/expository-essay-writer"><img src="/_/img/Expository-Essay.jpg" class="lazy" alt="Expository Essay"></a>
<a href="/expository-essay-writer"><h4>Expository Essay</h4></a>
<p>Our expository essay writing service delivers a perfect expository essay complete with definitions, facts, examples and stats.</p>
</div>
<div class="item">
<a href="/narrative-essay-writer"><img src="/_/img/Narrative-Essay.jpg" class="lazy" alt="Narrative Essay"></a>
<a href="/narrative-essay-writer"><h4>Narrative Essay</h4></a>
<p>Our narrative essay writers are master in the art of story-telling and making your essays engaging so you can get the best grade.</p>
</div>
</div>
脚本
<script>
$('.owl-carousel').owlCarousel({
loop:true,
margin:10,
responsiveClass:true,
autoplay:true,
autoplayTimeout:2000,
rewindSpeed : 1000,
responsive:{
0:{
items:1,
nav:true
},
600:{
items:2,
nav:false
},
1000:{
items:3,
nav:true,
}
}
})
</script>
延迟加载
<script>
$(function() {
$('.lazy').lazy({
beforeLoad: function(element){
console.log('image "' +element.data('src')+ '" is about to be loaded');
},
afterLoad: function(element) {
console.log('image "' +element.data('src') + '" was loaded successfully');
},
onError: function(element) {
console.log('error');
},
onFinishedAll: function() {
console.log('lazy instance is about to be destroyed')
}
});
});
</script>
请帮助我做错了什么,我也尝试过更改脚本的顺序但是没有 luck.My 网站是活的 here
这只是一个小问题。请为 .owl-item
添加以下代码。
.owl-item {
display: inline-block;
}
将此添加到 owl 项
.owl-item {
display: inline-block;
}
还有一期: 我假设 div 之外的内容应该被隐藏
.owl-carousel{
overflow:hidden;
}