PSA: Too big/wide slider on initialization

See original GitHub issue

When your swiper slider initializes too big (sometimes even far, far wider than the page), this could happen from the slider wrapper element being inside a CSS flexbox/grid container. The following styles fix the issue:

.swiper-container {
  width: 100%;
  max-width: 100%;
  max-height: 100vh;
  // CSS Grid/Flexbox bug size workaround
  // @see https://github.com/kenwheeler/slick/issues/982
  min-height: 0;
  min-width: 0;
}

It also contains a fix for Firefox and it also works with the Slick slider (and probably other like Splide). I had to search quite a bit to find a working solution, so I hope this is helpful for me in the future and other developers, enjoy!

Related issues: https://github.com/nolimits4web/Swiper/issues/312 https://github.com/nolimits4web/swiper/issues/2095 https://github.com/nolimits4web/Swiper/issues/312 https://github.com/nolimits4web/swiper/issues/109 https://github.com/nolimits4web/Swiper/issues/153 https://github.com/nolimits4web/Swiper/issues/153 https://github.com/nolimits4web/swiper/issues/2095

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:30
  • Comments:15

github_iconTop GitHub Comments

20reactions
kronthtocommented, Nov 11, 2021

This may be relevant too, it solved it for us: https://stackoverflow.com/a/53022198/7362396 It was added on a parent container flexitem many layers above the Swiper.

.main { /* flex item, child of d-flex */
...
    min-width: 0;
}

By default the flex items (children of flex layout) have the min-width set to auto

15reactions
Codisycommented, Nov 22, 2020

Если у вас проблема с swiper и grid layouts, когда у далекого от слайдера родителя установлены grid-template-columns в фракциях, то эти хаки уже не помогают просто так. Я имею ввиду ситуации когда например у body стоит grid-template-columns: 3fr 9fr; а уже у глубоко лежащего div внутри находится swiper, то ближайшему к swiper родителю надо установить display: grid; тогда эти хаки заработают.

Вот наглядный пример этого поведения: https://jsfiddle.net/codisy/2nc1dz4q/84/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why did the swiper-wrapper get ended up so big?
The slides get right height. The problem STILL IS with ech slide's content. They simply are higher then screen when you make it...
Read more >
PSA 3090 / 3080 transient load spikes north of 500w ... - Reddit
So after having some issues with my new 10900k / 3090 system cutting out and rebooting I narrowed it down to the power...
Read more >
PSA Service Guide: Agilent E4440A, E4443A, E4445A ...
The carton must be both large enough and strong enough to accommodate the instrument. Allow at least 3 to 4 inches on all...
Read more >
Please read: make it easier to help you - Julia Discourse
This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you...
Read more >
Mastersizer 3000 User Manual - Montana State University
samples which have very broad size distributions or contain large ... Do not force the cell into the instrument - only slide it...
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