简体   繁体   中英

prevArrow messing up the image width

I have implemented Slick.js to mine project but for some reason when I use nextArrow and prevArrow my picture gets cropped to around 60% of the width, I have tried to make a custom class which deffiness a width of 100% but that didn't solve the problem. Just checked only prevArrow causes a problem

Here is how it should look like: 预期的

Here is how it looks like: 现实

 $('.slider-one').not(".slick-initialized").slick({ autoplay: true, autoplaySpeed: 3000, dots: true, prevArrow: ".site-slider .slider-btn .prev", nextArrow: ".site-slider .slider-btn .next" });
 .wid { width: 100% !important; height: 500px; } /*Slider*/ .site-sider { position: relative; } .position-top { position: absolute; top: 45%; } .site-slider .slider-btn .prev, .site-slider .slider-btn .next { background-color: #091a5d; padding: 1rem 1.5rem; border-radius: 50%; color: white; margin: 0 1rem; opacity: 0; transition: opacity 1s ease; } .site-slider:hover .slider-btn .prev, .site-slider:hover .slider-btn .next { opacity: 0.9; } .right-0 { right: 0; } .slick-dots { left:50%; display: flex; justify-content: center; margin: 0; padding: 16px 0; list-style-type: none; position: absolute; bottom: 0; right: 50%; } .slick-dots li { margin: 0 0.6rem; } .slick-dots button { display: block; width: 8px; height: 8px; padding: 0; border: none; background-color: white; text-indent: -99999px; border-radius: 100%; } .slick-dots .slick-active button { transform: scale(2.5); box-shadow: 0px 3px 5px 1px rgba(0, 0, 0, 0.205); }
 <!DOCTYPE html> <html lang="en"> <head> <!--Font--> <script src="https://kit.fontawesome.com/158e82d513.js" crossorigin="anonymous"></script> <!--Slider--> <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.css" /> <!--Styles--> <link rel="stylesheet" href="./css/style.css" /> </head> <body> <main> <!--Slider--> <div class="container-fluid p-0"> <div class="site-slider"> <div class="slider-one"> <div> <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/1200px-Image_created_with_a_mobile_phone.png" class="wid img-fluid" alt="Slika 1"> </div> <div> <img src="https://www.talkwalker.com/images/2020/blog-headers/image-analysis.png" class="wid img-fluid" alt="Slika 2"> </div> <div> <img src="https://p.bigstockphoto.com/GeFvQkBbSLaMdpKXF1Zv_bigstock-Aerial-View-Of-Blue-Lakes-And--227291596.jpg" class="wid img-fluid" alt="Slika 3"> </div> </div> <div class="slider-btn"> <span class="prev position-top"><i class="fas fa-chevron-left"></i></span> <span class="next position-top right-0"><i class="fas fa-chevron-right"></i></span> </div> </div> </div> </main> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.min.js"></script> <script src="js/main.js"></script> </body>

So if anyone knows how to solve this, help a brother out :) <3

Instead of class use image directly

$('.slider-one').not(".slick-initialized").slick({
  prevArrow:"<img class='a-left control-c prev slick-prev' src='../images/shoe_story/arrow-left.png'>",
  nextArrow:"<img class='a-right control-c next slick-next' src='../images/shoe_story/arrow-right.png'>"  });

If Your are using bootstrap 3 Use this

.slick-prev:before, .slick-next:before {
            font-family: "Glyphicons Halflings","slick", sans-serif;
            font-size: 40px;
    }
    .slick-prev:before { content: "\e257"; }
    .slick-next:before { content: "\e258"; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM