Javascript 如何设置上一个/下一个箭头按钮的样式?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27403501/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 00:06:50  来源:igfitidea点击:

How to style prev/next arrows button?

javascriptjquerycsshtml

提问by iori

GOAL

目标

I've been trying to modify the slick.cssto fit the style I need in my site. I got the slick.cssfrom here.

我一直在尝试修改slick.css以适合我在我的网站中需要的样式。我slick.css这里得到的。

Now

现在

  • I want to make the arrow (left + right) bigger
  • For icons, I want to use the one with no circle-borderaround it.
  • I like fa-chevron-rightand fa-chevron-left
  • 我想让箭头(左+右)更大
  • 对于图标,我想使用没有circle-border周围的那个。
  • 我喜欢fa-chevron-rightfa-chevron-left


What have I tried ?

我试过什么?

portion of slick.css

的一部分 slick.css

.slick-prev, .slick-next { position: absolute; display: block; height: 200px; width: 50px; line-height: 0; font-size: 0; cursor: pointer; background: transparent; color: transparent; top: 50%; margin-top: -10px; padding: 0; border: none; outline: none; }
.slick-prev:hover, .slick-prev:focus, .slick-next:hover, .slick-next:focus { outline: none; background: transparent; color: transparent; }
.slick-prev:hover:before, .slick-prev:focus:before, .slick-next:hover:before, .slick-next:focus:before { opacity: 1; }
.slick-prev.slick-disabled:before, .slick-next.slick-disabled:before { opacity: 0.25; }

.slick-prev:before, .slick-next:before { font-family: "slick"; font-size: 20px; line-height: 1; color: red; opacity: 0.75; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }



.slick-prev { left: -10px; top: 70px;  }
[dir="rtl"] .slick-prev { left: auto; right: -10px; top: 70px; }
.slick-prev:before { content: "←"; }
[dir="rtl"] .slick-prev:before { content: "→"; }

.slick-next { right: -10px; top: 70px; }
[dir="rtl"] .slick-next { left: -10px; top: 70px; right: auto; }
.slick-next:before { content: "→"; }
[dir="rtl"] .slick-next:before { content: "←"; }

HTML

HTML

<div class="row slick ">
// just a bunch of lists in here
</div>


Detail Photo

详细照片

Here is what I have now.

这是我现在所拥有的。

enter image description here

在此处输入图片说明

Here is what I want to have.

这是我想要的。

enter image description here

在此处输入图片说明



Question

  • Can someone help me resolve this ?

    I really appreciate your consideration and time. :)

  • 有人可以帮我解决这个问题吗?

    我非常感谢您的考虑和时间。:)

回答by saqibahmad

The Basic thing is its producing arrows by content property:

基本的事情是它通过内容属性产生箭头:

.slick-prev:before, .slick-next:before { font-family: "slick"; font-size: 40px; line-height: 1; color: red; opacity: 0.75; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }   

.slick-prev:before { content: "?"; }
[dir="rtl"] .slick-prev:before { content: "?"; }

[dir="rtl"] .slick-next { left: -10px; top: 70px; right: auto; }
.slick-next:before { content: "?"; }
[dir="rtl"] .slick-next:before { content: "?"; }

Replace these classes and after that just play with margin and positions properties to adjust the arrows, if this didnot fix the issue send me the http://jsfiddle.net/link i will send you the complete solution.

替换这些类,然后使用边距和位置属性来调整箭头,如果这不能解决问题,请向我发送http://jsfiddle.net/链接,我将向您发送完整的解决方案。

If want to use Font Awesome

如果想使用 Font Awesome

.slick-prev:before, .slick-next:before { font-family: FontAwesome; font-size: 40px; line-height: 1; color: red; opacity: 0.75; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }   

.slick-prev:before { content: "\f053"; }
[dir="rtl"] .slick-prev:before { content: "\f054"; }

[dir="rtl"] .slick-next { left: -10px; top: 70px; right: auto; }
.slick-next:before { content: "\f054"; }
[dir="rtl"] .slick-next:before { content: "\f053"; }

For list of Font icons visit http://astronautweb.co/snippet/font-awesome/and how to implement the font visit this thread Use font awesome icon as css content

有关字体图标列表,请访问http://astronautweb.co/snippet/font-awesome/以及如何实现字体访问此线程 使用字体真棒图标作为 css 内容

回答by Ilídio Martins

.slick-prev::before {
    font-family: FontAwesome;
    content: "\f0d9";
    font-size: 22px;
}  
.slick-next::before {
    font-family: FontAwesome;
    content:  "\f0da";
    font-size: 22px;        
}      
<link href="http://fontawesome.io/assets/font-awesome/css/font-awesome.css" rel="stylesheet"/>

<button type="button" class="slick-prev "></button>

<button type="button" class="slick-next "></button>

回答by par

If you are using sass you can set sass variables provided by slick.

如果您使用 sass,您可以设置 slick 提供的 sass 变量。

Refer: Add custom buttons on Slick Carousel

参考:在 Slick Carousel 上添加自定义按钮

回答by waleed zaki

<script type="text/javascript">
$(document).ready(function(){
    $('.responsive_com2').slick({
        arrows: false,
        dots:true,
        infinite: true,
        speed: 300,
        slidesToShow: 1,
        slidesToScroll: 1,
        slidesPerRow: 1,
        rows: 1,
    });

    $('.left_news').click(function(){
        $('.responsive_com2').slick('slickPrev');
    })

    $('.right_news').click(function(){
        $('.responsive_com2').slick('slickNext');
    })

});
</script>