更改 Slick 滑块中的箭头按钮
我想更改我光滑滑块中的箭头,但它没有改变.我想要下一个和上一个按钮作为图像.我已经尝试将它放在 <style>
中,但它仍然无法正常工作.我在哪里可以更改箭头设置?
光滑的主题 css@charset "UTF-8";
//默认变量$slick-font-path: "./fonts/" !default;$slick-font-family: "slick" !default;$slick-loader-path: "./" !default;$slick-arrow-color: white !default;$slick-dot-color: black !default;$slick-dot-color-active: $slick-dot-color !default;$slick-prev-character: "←" !default;$slick-next-character: "→" !default;$slick-dot-character: "•" !default;$slick-dot-size: 6px !default;$slick-opacity-default: 0.75 !default;$slick-opacity-on-hover: 1 !default;$slick-opacity-not-active: 0.25 !default;@function slick-image-url($url) {@if 函数存在(图像 URL){@return image-url($url);}@别的 {@return url($slick-loader-path + $url);}}@function slick-font-url($url) {@if 函数存在(字体 URL){@return 字体-url($url);}@别的 {@return url($slick-font-path + $url);}}/* 滑块 */.slick-list {.slick-loading &{背景:#fff slick-image-url("ajax-loader.gif") center center no-repeat;}位置:绝对;边距:0 自动;}/* 图标 */@if $slick-font-family == "slick" {@字体脸{字体系列:光滑";src: slick-font-url("slick.eot");src: slick-font-url("slick.eot?#iefix") 格式("embedded-opentype"), slick-font-url("slick.woff") 格式("woff"), slick-font-url("slick.ttf") 格式("truetype"), slick-font-url("slick.svg#slick") 格式("svg");字体粗细:正常;字体样式:正常;}}/* 箭头 */.slick-prev,.slick-next {位置:绝对;显示:块;高度:20px;宽度:30px;行高:0px;字体大小:0px;光标:指针;背景:透明;颜色:透明;最高:50%;边距顶部:-10px;填充:0;边框:无;大纲:无;&:悬停,&:焦点{大纲:无;背景:透明;颜色:透明;&:之前{不透明度:$ slick-opacity-on-hover;}}&.slick-disabled:before {不透明度:$ slick-opacity-not-active;}}.slick-prev:before, .slick-next:before {字体家族:$ 光滑字体家族;字体大小:20px;行高:1;颜色:$光滑箭头颜色;不透明度:$slick-opacity-default;-webkit-font-smoothing:抗锯齿;-moz-osx-font-smoothing:灰度;}.slick-prev {左:-25px;[dir="rtl"] &{左:自动;右:-25px;}&:之前{内容:$slick-prev-character;[dir="rtl"] &{内容:$slick-next-character;}}}.slick-next {右:-25px;[dir="rtl"] &{左:-25px;右:自动;}&:之前{内容:$slick-next-character;[dir="rtl"] &{内容:$slick-prev-character;}}}/* 点 */.slick-滑块 {边距底部:30px;}.slick-dots {位置:绝对;底部:-45px;列表样式:无;显示:块;文本对齐:居中;填充:0;宽度:100%;李{位置:相对;显示:内联块;高度:20px;宽度:20px;边距:0 5px;填充:0;光标:指针;按钮 {边框:0;背景:透明;显示:块;高度:20px;宽度:20px;大纲:无;行高:0px;字体大小:0px;颜色:透明;填充:5px;光标:指针;&:悬停,&:焦点{大纲:无;&:之前{不透明度:$ slick-opacity-on-hover;}}&:之前{位置:绝对;顶部:0;左:0;内容:$圆点字符;宽度:20px;高度:20px;字体家族:$ 光滑字体家族;字体大小:$ 圆点大小;行高:20px;文本对齐:居中;颜色:$光滑点颜色;不透明度:$ slick-opacity-not-active;-webkit-font-smoothing:抗锯齿;-moz-osx-font-smoothing:灰度;}}&.slick-active 按钮:之前 {颜色:$slick-dot-color-active;不透明度:$slick-opacity-default;}}}
流畅的 CSS
/* 滑块 */.slick-滑块 {位置:相对;边距:0 自动;显示:块;box-sizing:边框框;-moz-box-sizing:边框框;-webkit-touch-callout:无;-webkit 用户选择:无;-khtml-用户选择:无;-moz 用户选择:无;-ms 用户选择:无;用户选择:无;-ms-touch-action: pan-y;触摸动作:pan-y;-webkit-tap-highlight-color:透明;}.slick-list {位置:相对;溢出:隐藏;显示:块;边距:0 自动;填充:0;&:焦点{大纲:无;}&.拖动{光标:指针;光标:手;}}.slick-slider .slick-track,.slick-滑块 .slick-list {-webkit-transform: translate3d(0, 0, 0);-moz-transform: translate3d(0, 0, 0);-ms-transform: translate3d(0, 0, 0);-o-transform: translate3d(0, 0, 0);变换: translate3d(0, 0, 0);}.slick-track {位置:相对;左:0;顶部:0;显示:块;&:之前,&:{之后内容: "";显示:表格;}&:{之后明确:两者;}.slick-loading &{可见性:隐藏;}}.slick-slide {向左飘浮;最小高度:1px;[dir="rtl"] &{浮动:对;}图像{显示:块;}&.slick-loading img {显示:无;}显示:无;&.拖动 img {指针事件:无;}.slick-initialized &{显示:块;}.slick-loading &{可见性:隐藏;}.slick-vertical &{显示:块;高度:自动;边框:1px 实心透明;}}
网站预览
解决方案Slick 有一个非常简单的方法来自定义它的按钮,通过它自己的配置中的两个变量:prevArrow
和 nextArrow代码>.
这两种类型都是:字符串(html | jQuery 选择器)|对象(DOM 节点 | jQuery 对象),所以在您的设置光滑滑块中,您可以设置类:
prevArrow: $('.prev')下一个箭头:$('.next')
并为这些元素添加您想要的样式.
例如:
//HTML<div class="滑块框_clearfix"><div class="slick-slider"><img src="img/home_carousel/home_carorusel_1.jpg"></div><img src="img/home_carousel/home_carorusel_2.jpg"></div><img src="img/home_carousel/home_carorusel_3.jpg"></div><img src="img/home_carousel/home_carorusel_4.jpg"></div></div></div><div class="paginator-center text-color text-center"><h6>VER MAS LANZAMIENTOS</h6><ul><li class="prev"></li><li class="next"></li></ul></div>//JS$(文档).ready(函数 () {$('.slick-slider').slick({中心模式:真,centerPadding: '60px',幻灯片显示:3,prevArrow: $('.prev'),nextArrow: $('.next'),});//CSS.分页器{位置:相对;浮动:对;边距底部:20px;李{边距顶部:20px;位置:相对;向左飘浮;右边距:20px;&.prev{显示:块;高度:20px;宽度:20px;背景: url('../img/back.png') 不重复;}&.下一个{显示:块;高度:20px;宽度:20px;背景: url('../img/next.png') 不重复;}}}
I want to change the arrows in my slick slider but it does not change. I want the next and previous button as an image. I have tried putting it in a <style>
but it still not working. Where can I change the arrows setting?
slick theme css @charset "UTF-8";
// Default Variables
$slick-font-path: "./fonts/" !default;
$slick-font-family: "slick" !default;
$slick-loader-path: "./" !default;
$slick-arrow-color: white !default;
$slick-dot-color: black !default;
$slick-dot-color-active: $slick-dot-color !default;
$slick-prev-character: "←" !default;
$slick-next-character: "→" !default;
$slick-dot-character: "•" !default;
$slick-dot-size: 6px !default;
$slick-opacity-default: 0.75 !default;
$slick-opacity-on-hover: 1 !default;
$slick-opacity-not-active: 0.25 !default;
@function slick-image-url($url) {
@if function-exists(image-url) {
@return image-url($url);
}
@else {
@return url($slick-loader-path + $url);
}
}
@function slick-font-url($url) {
@if function-exists(font-url) {
@return font-url($url);
}
@else {
@return url($slick-font-path + $url);
}
}
/* Slider */
.slick-list {
.slick-loading & {
background: #fff slick-image-url("ajax-loader.gif") center center no-repeat;
}
position: absolute;
margin: 0 auto;
}
/* Icons */
@if $slick-font-family == "slick" {
@font-face {
font-family: "slick";
src: slick-font-url("slick.eot");
src: slick-font-url("slick.eot?#iefix") format("embedded-opentype"), slick-font-url("slick.woff") format("woff"), slick-font-url("slick.ttf") format("truetype"), slick-font-url("slick.svg#slick") format("svg");
font-weight: normal;
font-style: normal;
}
}
/* Arrows */
.slick-prev,
.slick-next {
position: absolute;
display: block;
height: 20px;
width: 30px;
line-height: 0px;
font-size: 0px;
cursor: pointer;
background: transparent;
color: transparent;
top: 50%;
margin-top: -10px;
padding: 0;
border: none;
outline: none;
&:hover, &:focus {
outline: none;
background: transparent;
color: transparent;
&:before {
opacity: $slick-opacity-on-hover;
}
}
&.slick-disabled:before {
opacity: $slick-opacity-not-active;
}
}
.slick-prev:before, .slick-next:before {
font-family: $slick-font-family;
font-size: 20px;
line-height: 1;
color: $slick-arrow-color;
opacity: $slick-opacity-default;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.slick-prev {
left: -25px;
[dir="rtl"] & {
left: auto;
right: -25px;
}
&:before {
content: $slick-prev-character;
[dir="rtl"] & {
content: $slick-next-character;
}
}
}
.slick-next {
right: -25px;
[dir="rtl"] & {
left: -25px;
right: auto;
}
&:before {
content: $slick-next-character;
[dir="rtl"] & {
content: $slick-prev-character;
}
}
}
/* Dots */
.slick-slider {
margin-bottom: 30px;
}
.slick-dots {
position: absolute;
bottom: -45px;
list-style: none;
display: block;
text-align: center;
padding: 0;
width: 100%;
li {
position: relative;
display: inline-block;
height: 20px;
width: 20px;
margin: 0 5px;
padding: 0;
cursor: pointer;
button {
border: 0;
background: transparent;
display: block;
height: 20px;
width: 20px;
outline: none;
line-height: 0px;
font-size: 0px;
color: transparent;
padding: 5px;
cursor: pointer;
&:hover, &:focus {
outline: none;
&:before {
opacity: $slick-opacity-on-hover;
}
}
&:before {
position: absolute;
top: 0;
left: 0;
content: $slick-dot-character;
width: 20px;
height: 20px;
font-family: $slick-font-family;
font-size: $slick-dot-size;
line-height: 20px;
text-align: center;
color: $slick-dot-color;
opacity: $slick-opacity-not-active;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
}
&.slick-active button:before {
color: $slick-dot-color-active;
opacity: $slick-opacity-default;
}
}
}
slick css
/* Slider */
.slick-slider {
position: relative;
margin: 0 auto;
display: block;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-ms-touch-action: pan-y;
touch-action: pan-y;
-webkit-tap-highlight-color: transparent;
}
.slick-list {
position: relative;
overflow: hidden;
display: block;
margin: 0 auto;
padding: 0;
&:focus {
outline: none;
}
&.dragging {
cursor: pointer;
cursor: hand;
}
}
.slick-slider .slick-track,
.slick-slider .slick-list {
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
-o-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.slick-track {
position: relative;
left: 0;
top: 0;
display: block;
&:before,
&:after {
content: "";
display: table;
}
&:after {
clear: both;
}
.slick-loading & {
visibility: hidden;
}
}
.slick-slide {
float: left;
min-height: 1px;
[dir="rtl"] & {
float: right;
}
img {
display: block;
}
&.slick-loading img {
display: none;
}
display: none;
&.dragging img {
pointer-events: none;
}
.slick-initialized & {
display: block;
}
.slick-loading & {
visibility: hidden;
}
.slick-vertical & {
display: block;
height: auto;
border: 1px solid transparent;
}
}
preview of the site
解决方案Slick has a very easy way to customize its buttons through two variables in its own configuration: prevArrow
and nextArrow
.
Both types are: string (html | jQuery selector) | object (DOM node | jQuery object), so in your settings slick slider you can set the classes:
prevArrow: $('.prev')
nextArrow: $('.next')
and add to these elements the styles you want.
For example:
//HTML
<div class="slider-box _clearfix">
<div class="slick-slider">
<div>
<img src="img/home_carousel/home_carorusel_1.jpg">
</div>
<div>
<img src="img/home_carousel/home_carorusel_2.jpg">
</div>
<div>
<img src="img/home_carousel/home_carorusel_3.jpg">
</div>
<div>
<img src="img/home_carousel/home_carorusel_4.jpg">
</div>
</div>
</div>
<div class="paginator-center text-color text-center">
<h6>VER MAS LANZAMIENTOS</h6>
<ul>
<li class="prev"></li>
<li class="next"></li>
</ul>
</div>
//JS
$(document).ready(function () {
$('.slick-slider').slick({
centerMode: true,
centerPadding: '60px',
slidesToShow: 3,
prevArrow: $('.prev'),
nextArrow: $('.next'),
});
//CSS
.paginator{
position: relative;
float: right;
margin-bottom: 20px;
li{
margin-top: 20px;
position: relative;
float: left;
margin-right: 20px;
&.prev{
display: block;
height: 20px;
width: 20px;
background: url('../img/back.png') no-repeat;
}
&.next{
display: block;
height: 20px;
width: 20px;
background: url('../img/next.png') no-repeat;
}
}
}
相关文章