问题
I'm using Owlcarousel 2 for sliding over multiple divs, the problem is that inside each "sliding-page" there are some elements positioned as absolute (relative not working neither), and they are not visible while animating, they just "blick-in" when the animation is finished.
This is what my html looks like
<div id="owl-example" class="owl-carousel width-height-100">
<div class="advert-bg lazyOwl owl-lazy" data-src="ad_preview_new.png">
<div class="col-sm-6 col-md-7 col-lg-8 col-elg-9 pull-right position-absolute-text">
<div class="row">
<div class="advert-text gradient-white-bg">
<div class="col-sm-6 col-md-5 col-lg-4 col-elg-3 pull-right">
<div class="row">
<h1>Suikervrij beleg</h1>
<p>
Suikervrij beleg op de
brood, beschuit of pannenkoek?
Met onze suikervrije confituur
en chocopasta kan en mag het!
</p>
</div>
</div>
</div>
</div>
</div>
<img src="logo.png" class="image-logo" >
</div>
<div class="advert-bg lazyOwl owl-lazy" data-src="ad_preview_new.png">
<div style="margin:0 auto;padding:0;width:100px;height:100px;display:block;background:red;">
fds
</div>
<div class="col-sm-6 col-md-7 col-lg-8 col-elg-9 pull-right position-absolute-text">
<div class="row">
<div class="advert-text gradient-white-bg">
<div class="col-sm-6 col-md-5 col-lg-4 col-elg-3 pull-right">
<div class="row">
<h1>Suikervrij beleg</h1>
<p>
Suikervrij beleg op de
brood, beschuit of pannenkoek?
Met onze suikervrije confituur
en chocopasta kan en mag het!
</p>
</div>
</div>
</div>
</div>
</div>
<img src="logo.png" class="image-logo" >
</div>
<div class="advert-bg lazyOwl owl-lazy" data-src="http://localhost:8888/ad_preview_new2.png">
<img src="logo2.png" class="image-logo" >
</div>
</div>
And this is my JS file
$(document).ready(function() {
$("#owl-example").owlCarousel({
navigation : false, // Show next and prev buttons
pagination: false,
autoplay: true,
autoplayTimeout: 2000,
autoplaySpeed: 2000,
loop:true,
slideSpeed : 300,
paginationSpeed : 400,
items : 1,
itemsDesktop : false,
itemsDesktopSmall : false,
itemsTablet: false,
itemsMobile : false,
lazyLoad: true,
lazyContent:true
});
});
What can I do to make all the elements visible even while they are sliding-in (when they are sliding-out it works). It was working with Owlcarousel 1.
回答1:
In the owl.carousel.js file
REPLACE
transform: 'translate3d(' + coordinate + 'px,0px,0px)'
WITH
transform: 'translate3d(' + (coordinate-1) + 'px,0px,0px)'
And, in case of the owl.carousel.min.js file
REPLACE
transform: 'translate3d("+b+"px,0px,0px)'
WITH
transform: 'translate3d("+(b-1)+"px,0px,0px)'
Hope this helps!
回答2:
It seems it happens in Chrome, not Firefox. Possible solution is to modify the css:
.owl-carousel .owl-item { -webkit-backface-visibility: visible; }
Hope it helps.
回答3:
Had this same issue, 'relative' content was not showing and finally I found out that it's related to css 'transition' effect. So adding this to parent element fixed mine:
transition: all 0.3s ease;
来源:https://stackoverflow.com/questions/33015464/owlcarousel-2-elements-not-visible-while-translate3d