react-slick icon indicating copy to clipboard operation
react-slick copied to clipboard

Slick track width calculating width to large number

Open phc5 opened this issue 6 years ago • 27 comments

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

phc5 avatar Jun 12 '19 23:06 phc5

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

shererere avatar Jul 05 '19 14:07 shererere

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

GenoD avatar Aug 28 '19 22:08 GenoD

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 avatar Feb 10 '20 21:02 neomaxzero

@neomaxzero we used the following attributes in the container:

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

Good luck!!!

camilocagd avatar Feb 14 '20 22:02 camilocagd

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.

rajpraful avatar Mar 25 '20 17:03 rajpraful

overflow: hidden worked for me

HZooly avatar Apr 29 '20 16:04 HZooly

@HZooly thank you! This worked for me:

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

conary-h avatar Jul 04 '20 06:07 conary-h

@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..

Gennady-G avatar Aug 27 '20 12:08 Gennady-G

@HZooly thank you! This worked for me:

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

worked for me

zamlahani avatar Aug 31 '21 08:08 zamlahani

@HZooly thank you! This worked for me:

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

You put to the

above or to itself?

DhruvinPatel78 avatar Mar 26 '22 07:03 DhruvinPatel78

we used the following attributes in the container

where can i find this "container"?

ramach05 avatar Jun 02 '22 15:06 ramach05

.slick-slider{ max-width: 100vw; width: 100%; overflow: hidden !important; }

Bharti-kumath avatar Jul 01 '22 06:07 Bharti-kumath

i am using .slick-slider{ max-width: 100vw; width: 100%; overflow: hidden !important; } but not working in mobile mode

shahrukh263 avatar Aug 02 '22 18:08 shahrukh263

@shahrukh263 Same with me. Working fine in desktop and tablet but not in mobile

varunpandey21 avatar Sep 01 '22 13:09 varunpandey21

我有同样的问题,发现一个祖先被设置为 flex 并且以某种方式放弃了计算

Very helpful to solve my problem, thank you

AaronSeaweed avatar Dec 06 '22 01:12 AaronSeaweed

I also found an ancestor which had a display: flex property. Its child had flex: 1, but I needed to add minWidth: {0} to fix it.

ilchoTaleski avatar Dec 10 '22 14:12 ilchoTaleski

When I applied flex-basis to the parent element, it caused the parent width to become too large. Therefore, I use width instead of flex-basis.

atulkkale avatar Jan 27 '23 13:01 atulkkale

.slick-slider{ max-width: 100vw; width: 100%; overflow: hidden !important; }

Very helpful to solve my problem, thank you so much.

HiralBrightness avatar Apr 04 '23 09:04 HiralBrightness

in my case was width: auto on some parent wrapper

0franco avatar Apr 24 '23 18:04 0franco

In my case it wasn't a flex container, but a grid one. It was using grid-template-rows without a grid-template-columns actually. I just had to add the property: grid-template-columns: 100%

IvaanTorres avatar May 10 '23 08:05 IvaanTorres

@HZooly thank you! This worked for me:

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

Thanks a ton for the solutions. After trying so many things, this worked for me..

dhruv-marutitech avatar Jun 02 '23 13:06 dhruv-marutitech

Thank you for your solution

On Fri, 2 Jun 2023 at 18:42, Dhruvkumar Saliya @.***> wrote:

@HZooly https://github.com/HZooly thank you! This worked for me:

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

Thanks a ton for the solutions. After trying so many things, this worked for me..

— Reply to this email directly, view it on GitHub https://github.com/akiran/react-slick/issues/1571#issuecomment-1573714056, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2ODVUVKKN6YSGETXQCIWBLXJHRDXANCNFSM4HXUOETA . You are receiving this because you commented.Message ID: @.***>

HiralBrightness avatar Jun 05 '23 04:06 HiralBrightness

hi please wrap it with container if its full width use container fluid and add utility classes for margin left right 0 and padding left right 0. then your slick slider calculation will be fine

niyasmn avatar Jun 13 '23 05:06 niyasmn

FWIW, I had the issue and the reason was that I missed this part of instructions:

Also install slick-carousel for css and font npm install slick-carousel // Import css files import "slick-carousel/slick/slick.css"; import "slick-carousel/slick/slick-theme.css";

After doing them the issue was gone.

vardan-arm avatar Jun 15 '23 10:06 vardan-arm

I also found an ancestor which had a display: flex property. Its child had flex: 1, but I needed to add minWidth: {0} to fix it.

It really worked, THANKS a lot!

AlexanderGalt avatar Jul 18 '23 22:07 AlexanderGalt