Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

334
Views
Swiper slider, how to reduce the width of the scrollbar

JavaScript

 const projectsSwiper = new Swiper(".projects__swiper-start", {
       speed: 1000,
    
             slidesPerView: 3,
    
             navigation: {
                nextEl: ".projects__swiper-next",
                prevEl: ".projects__swiper-prev",
             },
       watchOverFlow: true,
       simulateTouch: true,
    
       spaceBetween: 19,
    
       scrollbar: {
          el: ".projects__swiper-scroll",
          draggable: true,
          dragSize: 80,
       },
    });

HTML

<div class="projects__swiper-start swiper">
    <div class="projects__swiper swiper-wrapper">
        <div class="projects__swiper-slide swiper-slide">
            <div class="projects__swiper-img">
                <img src="images/projects/slide-1.jpg" alt="slide-1" />
            </div>
        </div>
        <div class="projects__swiper-slide swiper-slide">
            <div class="projects__swiper-img">
                <img src="images/projects/slide-2.jpg" alt="slide-2" />
            </div>
        </div>
        <div class="projects__swiper-slide swiper-slide">
            <div class="projects__swiper-img">
                <img src="images/projects/slide-3.jpg" alt="slide-3" />
            </div>
        </div>
        <div class="projects__swiper-slide swiper-slide">
            <div class="projects__swiper-img">
                <img src="images/projects/slide-4.jpg" alt="slide-4" />
            </div>
        </div>
    </div>
</div>

Now I have scrolled in full width, but I need to reduce it to 300px and place it in the center, as I found the slider to reduce, but with the width of the scroll, there is a problem.

Thank you very much in advance!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

dragSize - Size of scrollbar draggable element in px.

enter image description here

No API option to control the width of swiper-scrollbar (The wrapper). If you change this by custom CSS you destroy the way the scrollbar works.

/* will not work as it should */
.swiper-horizontal .swiper-scrollbar{
  width: 50%!important;
}

You should open Github Feature Req related to this idea: https://github.com/nolimits4web/swiper/issues

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!