我已经为我的bootstrap项目集成了光滑的轮播,我已经修改了slick-theme.css以进行一些自定义。我遇到了这个奇怪的问题,在响应模式下滑块完全错误,幻灯片重复,箭头(它们被定制为下一个和前一个按钮)显示为幻灯片。当我删除响应参数时,它可以正常工作。我想删除小屏幕尺寸的箭头。如果有人能帮助我解决这个问题,那就太好了。谢谢。
PS:编辑过的slick-theme.css文件的代码位于此代码段的css部分的底部。
$(window).load(function () {
$('.slider-main').slick({
arrows: true,
dots: false,
prevArrow: "<a class=\"slick-prev slider-slick-prev\">PREVIOUS</a>",
nextArrow: "<a class=\"slick-next slider-slick-next\">NEXT</a>",
slidesToShow: 1,
slidesToScroll: 1,
responsive: [
{
breakpoint: 767,
settings: {
arrows: false
}
}
]
});
});
.slider > div {
padding: 0 40px;
}
@media only screen and (max-width: 1200px) {
.slider > div {
padding: 0 10px;
}
}
.slider > div .slider-left {
padding: 0 16px 0 23px;
text-align: center;
}
@media only screen and (max-width: 1200px) {
.slider > div .slider-left {
padding: 0 5px 0 0;
}
}
@media only screen and (max-width: 767px) {
.slider > div .slider-left {
display: none;
}
}
.slider > div .slider-left > div {
border-left: 1px solid #e8e8e8;
border-right: 1px solid #e8e8e8;
border-bottom: 1px solid #e8e8e8;
margin-top: 13px;
}
.slider > div .slider-left > div > h2 {
background: #bbe3de;
color: #ffffff;
font-size: 21.36px;
margin: 0;
padding: 18px 0;
}
@media only screen and (max-width: 1200px) {
.slider > div .slider-left > div > h2 {
font-size: 19.36px;
padding: 18px 10px;
}
}
.slider > div .slider-left > div > div.left-description {
color: #afafaf;
font-size: 25px;
margin-top: 35px;
line-height: 1.2;
padding: 0 23px;
}
@media only screen and (max-width: 1200px) {
.slider > div .slider-left > div > div.left-description {
margin-top: 5px;
font-size: 17px;
padding: 0 5px;
}
}
.slider > div .slider-left > div > div.left-info {
color: #9d9d9d;
font-size: 17px;
margin-top: 28px;
line-height: 1.2;
padding: 0 4px;
}
@media only screen and (max-width: 1200px) {
.slider > div .slider-left > div > div.left-info {
margin-top: 5px;
}
}
.slider > div .slider-left > div > div.left-location {
color: #9d9d9d;
font-size: 25px;
margin-top: 2px;
}
@media only screen and (max-width: 1200px) {
.slider > div .slider-left > div > div.left-location {
font-size: 17px;
}
}
.slider > div .slider-left > div > div.left-read-more {
margin-top: 16px;
margin-bottom: 18px;
}
@media only screen and (max-width: 1200px) {
.slider > div .slider-left > div > div.left-read-more {
margin-top: 5px;
}
}
.slider > div .slider-left > div > div.left-read-more a {
color: #ec6b9c;
font-size: 22.29px;
-webkit-transition: color 0.2s ease;
-moz-transition: color 0.2s ease;
-ms-transition: color 0.2s ease;
-o-transition: color 0.2s ease;
transition: color 0.2s ease;
}
@media only screen and (max-width: 1200px) {
.slider > div .slider-left > div > div.left-read-more a {
font-size: 17px;
}
}
.slider > div .slider-left > div > div.left-read-more a:hover {
color: #bbe3de;
}
.slider > div .slider-main {
padding: 13px 39px 0 16px;
}
@media only screen and (max-width: 1200px) {
.slider > div .slider-main {
padding: 13px 0 0 5px;
}
}
.slider > div .slider-main .single-slide {
outline: none;
}
.slider > div .slider-main .single-slide:hover {
outline: none;
}
.slider > div .slider-main .single-slide:focus {
outline: none;
}
.slider > div .slider-main .single-slide img {
width: 100%;
outline: none;
}
.slider > div .slider-main .single-slide img:hover {
outline: none;
}
.slider > div .slider-main .single-slide img:focus {
outline: none;
}
.slider > div .slider-main .single-slide .slide-description {
position: absolute;
bottom: 18px;
right: 0;
text-transform: uppercase;
background: #ffffff;
padding: 10px 21px 5px 18px;
letter-spacing: -0.3px;
color: #878787;
font-size: 22.37px;
}
.slider > div .slider-main .single-slide .slide-description a {
margin-left: 4px;
letter-spacing: 0.5px;
display: inline-block;
color: #ec6b9c;
font-size: 15px;
-webkit-transition: color 0.2s ease;
-moz-transition: color 0.2s ease;
-ms-transition: color 0.2s ease;
-o-transition: color 0.2s ease;
transition: color 0.2s ease;
}
.slider > div .slider-main .single-slide .slide-description a:hover {
color: #bbe3de;
}
.slider > div .slider-left-mobile {
padding: 0 16px 0 23px;
text-align: center;
}
.slider > div .slider-left-mobile > div {
border-left: 1px solid #e8e8e8;
border-right: 1px solid #e8e8e8;
border-bottom: 1px solid #e8e8e8;
margin-top: 13px;
}
.slider > div .slider-left-mobile > div > h2 {
background: #bbe3de;
color: #ffffff;
font-size: 21.36px;
margin: 0;
padding: 18px 0;
}
.slider > div .slider-left-mobile > div > div.left-description {
color: #afafaf;
font-size: 25px;
margin-top: 35px;
line-height: 1.2;
padding: 0 23px;
}
.slider > div .slider-left-mobile > div > div.left-info {
color: #9d9d9d;
font-size: 17px;
margin-top: 28px;
line-height: 1.2;
padding: 0 4px;
}
.slider > div .slider-left-mobile > div > div.left-location {
color: #9d9d9d;
font-size: 25px;
margin-top: 2px;
}
.slider > div .slider-left-mobile > div > div.left-read-more {
margin-top: 16px;
margin-bottom: 18px;
}
.slider > div .slider-left-mobile > div > div.left-read-more a {
color: #ec6b9c;
font-size: 22.29px;
-webkit-transition: color 0.2s ease;
-moz-transition: color 0.2s ease;
-ms-transition: color 0.2s ease;
-o-transition: color 0.2s ease;
transition: color 0.2s ease;
}
.slider > div .slider-left-mobile > div > div.left-read-more a:hover {
color: #bbe3de;
}
/*slick theme customized*/
/* Arrows */
.slick-prev,
.slick-next {
position: absolute;
display: block;
font-size: 16.5px;
cursor: pointer;
background: #ffffff;
color: #878787;
top: 50%;
margin-top: -23px;
padding: 15px 17px;
border: none;
outline: none;
z-index: 1;
-webkit-transition: color 0.2s ease;
-moz-transition: color 0.2s ease;
-ms-transition: color 0.2s ease;
-o-transition: color 0.2s ease;
transition: color 0.2s ease;
}
.slick-prev:hover,
.slick-next:hover {
outline: none;
color: #ec6b9c;
}
.slick-prev {
left: 16px;
}
@media only screen and (max-width: 1200px) {
.slick-prev {
left: 5px;
}
}
[dir="rtl"] .slick-prev {
left: auto;
right: 39px;
}
@media only screen and (max-width: 1200px) {
[dir="rtl"] .slick-prev {
right: -1px;
}
}
.slick-next {
right: 39px;
}
@media only screen and (max-width: 1200px) {
.slick-next {
right: -1px;
}
}
[dir="rtl"] .slick-next {
left: 16px;
right: auto;
}
@media only screen and (max-width: 1200px) {
[dir="rtl"] .slick-next {
left: 5px;
}
}
/* Dots */
.slick-slider {
margin-bottom: 5px;
}
.slick-dots {
position: absolute;
bottom: -45px;
list-style: none;
display: block;
text-align: center;
padding: 0;
width: 100%;
}
.slick-dots li {
position: relative;
display: inline-block;
height: 20px;
width: 20px;
margin: 0 5px;
padding: 0;
cursor: pointer;
}
.slick-dots li 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;
}
.slick-dots li button:hover, .slick-dots li button:focus {
outline: none;
}
.slick-dots li button:before {
position: absolute;
top: 0;
left: 0;
width: 20px;
height: 20px;
font-size: 6px;
line-height: 20px;
text-align: center;
-webkit-font-smoothing: antialiased;
}
/*# sourceMappingURL=slick-theme.css.map */
/*slick theme customized*/
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.5.7/slick.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.5.7/slick.js"></script>
<div class="container-fluid">
<div class="row slider">
<div class="col-xs-12">
<div class="col-xs-12 col-sm-3 slider-left">
<div class="col-xs-12">
<h2>PARTY DECORATIORS</h2>
<div class="col-xs-12 left-description">
LOOKING for someone to come and DECORATE your NEXT PARTY?
</div>
<div class="col-xs-12 left-info">
We will come and
<br>
decorate your children's party
<br>
within a 50 mile radius of
</div>
<div class="col-xs-12 left-location">
IPSWICH
</div>
<div class="col-xs-12 left-read-more">
<a href="#">READ MORE</a>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-9 slider-main">
<div class="col-xs-12 single-slide">
<img src="https://placehold.it/350x150" alt=""/>
<div class="slide-description">
book us to decorate your next party!
<a href="#">CLICK HERE</a>
</div>
</div>
<div class="col-xs-12 single-slide">
<img src="https://placehold.it/350x150" alt=""/>
<div class="slide-description">
book us to decorate your next party!
<a href="#">CLICK HERE</a>
</div>
</div>
<div class="col-xs-12 single-slide">
<img src="https://placehold.it/350x150" alt=""/>
<div class="slide-description">
book us to decorate your next party!
<a href="#">CLICK HERE</a>
</div>
</div>
</div>
</div>
</div>
</div>
更新:最新更新1.5.9修复了此问题。
答案 0 :(得分:2)
噢!我现在看到了。我认为这是滑块脚本错误,因为它在滑块div中生成另一个控件标签。因此,如果您只想删除小屏幕尺寸的控件,请使用以下css并从滑块脚本中删除响应属性。
@media screen and (max-width:767px)
{
a.slick-arrow{
display:none !important;
}
}
答案 1 :(得分:2)
我有同样的问题。将slick.js降级到旧版本(1.3.15)后,问题就解决了。