React-slick: Slick track width calculating width to large number

Created on 13 Jun 2019  路  8Comments  路  Source: akiran/react-slick

Has anyone run into this issue and know how to resolve it? I am seeing slick-track's width being calculated incorrectly to a very large number on mobile devices (ios chrome and safari, haven't tested android). The width is correct on desktop chrome, firefox, edge, ie11...

Capture

Most helpful comment

@neomaxzero we used the following attributes in the container:

max-width: 100vw;
width: 100%;

Good luck!!!

All 8 comments

In my case, adding following rule to the container of slick slider fixed the problem.
width: 100%

I had the same issue, found that an ancestor was set to flex and was throwing off the calculation somehow

I also have this issue from Chrome 80. Tried multiple options like the ones suggested here:
https://github.com/akiran/react-slick/issues/230

But still no luck.

@neomaxzero we used the following attributes in the container:

max-width: 100vw;
width: 100%;

Good luck!!!

I also have the same issue and giving width:100% also not working.

I can't use 100vw as I have side navbar and it's dynamic in different screens.

overflow: hidden worked for me

@HZooly thank you! This worked for me:

.slider-container {
    max-width: 100vw;
    width: 100%;
    overflow: hidden;
}

@HZooly thank you! This worked for me:

.slider-container {
    max-width: 100vw;
    width: 100%;
    overflow: hidden;
}

And what can we do if we don't know vw and width is different in different cases..
My banner could be 80vw or 100vw depending of situation...

Anybody resolved?..

update: the only 50/50 working solution I found here:
https://stackoverflow.com/questions/45962822/slick-slider-not-working-in-a-flex-container

.container-wrap {
    position:absolute;
    top:150px;
    bottom:0px;
    width:85%;
    height:100%;
}

But is not solution for me..

Was this page helpful?
0 / 5 - 0 ratings