javascript - Owl carousel fade not working with bootstrap 4
问题描述
I have an owl carousel slider and I need fade effect. According to owl carousel doc, needs to add animate css library. So I have added it to my site. But it's not working at all. Seems all stacked behind each slide.
Here are my options for slider
$('.home-slider-2').owlCarousel({
animateOut: 'slideOutDown',
animateIn: 'flipInX',
items:1,
margin:30,
stagePadding:30,
smartSpeed:450
});
So I tried this way,
- Remove bootstrap 4 jQuery slim and add full version.
- Adjust smartSpeed:450 to higher
Still no any luck. Here is my fiddle
Any help?
解决方案
这里的问题是Owl carousel
使用. 在最新版本中,我们需要向该元素添加类,我们想要动画,而在版本中,我们需要向元素添加类。3.x
animate.css
animate.css (4.x)
animate__animated
3.x
animated
Owl carousel
用于自动添加animated
类,你只需要指定你想要的动画。
现在,有两种方法可以做到:
您可以将链接标签更改为:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.2/animate.min.css"/>
从:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">
或者
js
根据新版本更改中的类,如下所示:$(".home-slider-2").owlCarousel({ animateOut: "animate__animated animate__slideOutDown", animateIn: "animate__animated animate__flipInX", items: 1, smartSpeed: 450 });
在 Codepen 上检查它:https ://codepen.io/manaskhandelwal1/pen/ZEBBXPw
笔记
该animate.css
文件应该在Owl carousel
文件之上。
你应该使用一些更好的库来这样做,因为即使是OwlCarousel2 GitHub也说
是的,所以这已经死了,你自己帮个忙,然后改用小滑块
推荐阅读
- python-3.x - 服务总线未在 Azure 上触发,在本地工作
- angular - Angular Material 反应形式:为每个验证器显示不同的错误消息
- css - 为什么我的媒体查询范围不能正常工作?
- vuejs2 - 带有 flex/grid 包装器的 vue 过渡组项目移动到左上角
- android - HTML 原生应用无法在大尺寸手机上正确适配横向模式。不能强行合身
- node.js - JWT 身份验证授权不起作用
- python - •选择一个有效的选项。该选择不是可用的选择之一
- firebase - 无法使用 Flutter Web 访问 Cloud Firestore
- python - 尝试下载 pdf 文件时崩溃
- pandas - 我如何比较熊猫中的值并更改值