Owl Carousel搭配Animate.css轮播切换动画不生效问题求助
解决Owl Carousel搭配Animate.css动画不生效问题
你的配置存在参数冲突与必要配置缺失,按以下步骤修改即可实现「前一张卡片缩小消失、后一张卡片同步滑入」的预期效果:
- 清理冲突参数:删除1.x版本遗留的
singleItem: true配置,该参数和items:4互斥,会导致布局逻辑混乱阻断动画执行 - 替换匹配的动画类:将
animateIn改为animate__slideInRight匹配你要的滑入效果,animateOut保留animate__zoomOut实现缩小消失效果 - 补充动画必要配置:新增
autoHeight: false避免高度重绘打断动画,调整smartSpeed和slideSpeed为1000,和Animate.css默认动画时长对齐,保证进出动画同步 - 检查基础类配置:手动给所有轮播项添加
animate__animated基础类,Owl Carousel不会自动注入该类
修改后完整代码如下:
$(document).ready(function() { $("#owl-example").owlCarousel({ navigation: true, navigationText: ["", ""], loop: true, autoplay: true, animateIn: 'animate__slideInRight', animateOut: 'animate__zoomOut', items:4, margin:30, stagePadding:100, smartSpeed:1000, slideSpeed: 1000, autoHeight: false, itemsDesktop : [1199,3], itemsDesktopSmall : [979,3] }); });
如果修改后仍有动画不同步的问题,可添加以下CSS强制对齐动画时序:
.owl-item { animation-duration: 1s !important; animation-fill-mode: both !important; }
内容的提问来源于stack exchange,提问作者Sahil Malhan
相关产品推荐
相关产品推荐

