use*_*549 24 javascript jquery carousel
昨天我向一位顾客推出了一个网站.我总是使用猫头鹰旋转木马,因为它的响应.客户如何讨厌以前的,接下来的话,并希望将它们改为箭头.
所以我更新了我的脚本.js文件.这很容易做到,我想分享它.
$(document).ready(function(){
$('.owl-carousel').owlCarousel({
nav:true,
responsive:{
...
})
$( ".owl-prev").html('<i class="fa fa-chevron-left"></i>');
$( ".owl-next").html('<i class="fa fa-chevron-right"></i>');
});
Run Code Online (Sandbox Code Playgroud)
在那里,你有它.您可以随时添加更多样式.(我第一次使用答案你自己的问题希望这是正确的地方/方式)
Rub*_*ain 49
如果您正在使用Owl Carousel 2,那么您应该使用以下内容:
$(".category-wrapper").owlCarousel({
items : 4,
loop : true,
margin : 30,
nav : true,
smartSpeed :900,
navText : ["<i class='fa fa-chevron-left'></i>","<i class='fa fa-chevron-right'></i>"]
});
Run Code Online (Sandbox Code Playgroud)
Pan*_*ndy 17
其他可能使用Owl Carousel v 1.3.2的人的说明:
您可以在启用导航的设置中替换导航文本.
navigation:true,
navigationText: [
"<i class='fa fa-chevron-left'></i>",
"<i class='fa fa-chevron-right'></i>"
]
Run Code Online (Sandbox Code Playgroud)
小智 14
如果您使用最新的 Owl Carousel 2 版本。您可以用 fontawesome 图标替换导航文本。代码如下。
$('.your-class').owlCarousel({
loop: true,
items: 1, // Select Item Number
autoplay:true,
dots: false,
nav: true,
navText: ["<i class='fa fa-long-arrow-left'></i>","<i class='fa fa-long-arrow-right'></i>"],
});
Run Code Online (Sandbox Code Playgroud)
Cod*_*Spy 13
在此处完成教程
演示 链接
的JavaScript
$('.owl-carousel').owlCarousel({
margin: 10,
nav: true,
navText:["<div class='nav-btn prev-slide'></div>","<div class='nav-btn next-slide'></div>"],
responsive: {
0: {
items: 1
},
600: {
items: 3
},
1000: {
items: 5
}
}
});
Run Code Online (Sandbox Code Playgroud)
导航的CSS样式
.owl-carousel .nav-btn{
height: 47px;
position: absolute;
width: 26px;
cursor: pointer;
top: 100px !important;
}
.owl-carousel .owl-prev.disabled,
.owl-carousel .owl-next.disabled{
pointer-events: none;
opacity: 0.2;
}
.owl-carousel .prev-slide{
background: url(nav-icon.png) no-repeat scroll 0 0;
left: -33px;
}
.owl-carousel .next-slide{
background: url(nav-icon.png) no-repeat scroll -24px 0px;
right: -33px;
}
.owl-carousel .prev-slide:hover{
background-position: 0px -53px;
}
.owl-carousel .next-slide:hover{
background-position: -24px -53px;
}
Run Code Online (Sandbox Code Playgroud)
Swo*_*d I 12
以下代码适用于猫头鹰旋转木马.
https://github.com/OwlFonk/OwlCarousel
$(".owl-carousel").owlCarousel({
items: 1,
autoplay: true,
navigation: true,
navigationText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"]
});
Run Code Online (Sandbox Code Playgroud)
对于OwlCarousel2
https://owlcarousel2.github.io/OwlCarousel2/docs/api-options.html
$(".owl-carousel").owlCarousel({
items: 1,
autoplay: true,
nav: true,
navText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"]
});
Run Code Online (Sandbox Code Playgroud)
这是您$(document).ready()使用FontAwesome图标在函数中执行此操作的方法:
$( ".owl-prev").html('<i class="fa fa-chevron-left"></i>');
$( ".owl-next").html('<i class="fa fa-chevron-right"></i>');
Run Code Online (Sandbox Code Playgroud)