For my icons I used Font Awesome but you could use anything similar. Note the navText in the javascript code, this is where you put your custom HTML. I guess you could use an image too (or put it in the background of the .owl-next and .owl-prev divs. Note I used transform to make my arrows higher.
8条答案
按热度按时间643ylb081#
I just did this yesterday:)
Firstly make sure nav is turned on in the config
https://owlcarousel2.github.io/OwlCarousel2/docs/api-options.html
This will inject the controls into the DOM, see
https://owlcarousel2.github.io/OwlCarousel2/docs/api-classes.html
Next use CSS to position the Next and Prev controls, this is what I used:
For my icons I used Font Awesome but you could use anything similar. Note the navText in the javascript code, this is where you put your custom HTML. I guess you could use an image too (or put it in the background of the .owl-next and .owl-prev divs. Note I used transform to make my arrows higher.
eit6fx6z2#
只是从上面的@KevinSol回答中得到了一点点改进。
https://stackoverflow.com/a/40449552/10933080
这是我的JS代码:
和我CSS代码:
ocebsuys3#
自定义Owl Carousel 2导航箭头
来源Link
工作演示Link
更新navText属性
添加CSS样式
mu0hgdu04#
HTML标记
CSS样式滑块是类名
滑块激活
prdp8dxp5#
我建议使用以下简单样式:
和以下配置:
ogsagwnx6#
所有滑块为类名
fv2wmkja7#
如果你只是想用一些CSS和一个箭头在一个边缘,另一个在另一个边缘没有边距,但它覆盖滑块,你可以使用这个CSS:
xqkwcwgp8#
第一个