question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

move pagination outside of <swiper></swiper>

See original GitHub issue

In all the examples, even with custom pagination, the pagination html is contained within the <swiper></swiper> block like so…

<swiper>
  <swiper-slide></swiper-slide>
  <div class="swiper-pagination"  slot="pagination"></div>
</swiper>

Is it possible to move the pagination outside the <swiper></swiper> block? For instance, move it into the footer

<swiper>
  <swiper-slide></swiper-slide>
</swiper>
<footer>
  <div class="swiper-pagination"  slot="pagination"></div>
</footer>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

34reactions
cdrandincommented, Apr 5, 2019

I wanted to present a simple solution that seems to get the job easily with some css changes.

.swiper-container {
    overflow: visible;
}
.swiper-pagination {
    position: absolute;
    bottom: -25px; // should be fine as is, but adjust to your liking
}

assuming your html structure is the same as in the docs

<!-- Slider main container -->
<div class="swiper-container">
    <!-- Additional required wrapper -->
    <div class="swiper-wrapper">
        <!-- Slides -->
        <div class="swiper-slide">Slide 1</div>
        <div class="swiper-slide">Slide 2</div>
        <div class="swiper-slide">Slide 3</div>
        ...
    </div>
    <!-- If we need pagination -->
    <div class="swiper-pagination"></div>

    <!-- If we need navigation buttons -->
    <div class="swiper-button-prev"></div>
    <div class="swiper-button-next"></div>

    <!-- If we need scrollbar -->
    <div class="swiper-scrollbar"></div>
</div>
27reactions
tbenbowcommented, May 2, 2020

I moved pagination outside the swiper with absolute positioning. I added padding to the bottom of the container to get around needing to set overflow to visible.

.swiper-container {
  padding-bottom: 35px;
}
.swiper-container-horizontal > .swiper-pagination {
    position: absolute;
    bottom: 0;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Reactjs,swiperjs,Css-How to move the pagination outside of ...
If you want to move the pagination out then it would be easier to place it outside of the Swiper container rather than...
Read more >
PaginationOptions | Swiper - v8.4.5
Defines which HTML tag will be used to represent single pagination bullet. Only for 'bullets' pagination type. default. 'span'. Optional clickable.
Read more >
Swiper custom pagination - CodePen
URL Extension Required. When linking another Pen as a resource, make sure you use a URL Extension of the type of code you...
Read more >
SwiperJS - Tips and Good Practice - OXYGEN4FUN
We have added a new container (that we have called swiper-container), and we have moved the pagination and buttons so now they are...
Read more >
Swiper Demo 7 Custom Pagination - StackBlitz
<!DOCTYPE html> · <html lang="en"> · <head> · <meta charset="utf-8"> · <title>Swiper demo</title> · <!-- Link Swiper's CSS --> · <link rel="stylesheet" href="https:// ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found