davidjerleke / embla-carousel

A lightweight carousel library with fluid motion and great swipe precision.
https://www.embla-carousel.com
MIT License
5.49k stars 167 forks source link

White space after the last slide #399

Closed haroldao closed 1 year ago

haroldao commented 1 year ago

Bug is related to

Embla Carousel version

Describe the bug

Codepen

haroldao commented 1 year ago

image image

davidjerleke commented 1 year ago

Hi @haroldao,

Thanks for your question. The problem you describe is most likely caused by faulty CSS and not the Embla engine. You can confirm if this is the case by disabling the Embla script entirely and see how your carousel looks without it. If the space is still there, it’s a CSS problem on your side.

I’m not sure what you want to achieve, but if I were to guess, you want a setup like this example in the docs (but of course, with different spacing etc.). Try working with the CSS in that example and customize it.

Best, David

haroldao commented 1 year ago

Hi David! My bad!

Thank you, I'll take a look at it :)

haroldao commented 1 year ago

I've updated my Codepen... I still have the issue ... 👀

davidjerleke commented 1 year ago

@haroldao it doesn’t seem like your slides are respecting their sizes because the content is stretching them:

flex: 0 0 calc(30% - 3.2rem);

…This can happen sometimes so try adding min-width: 0; to your slides. Also, use the box sizing: border-box; approach (read here why) on all your CSS. You didn’t apply spacing the same way as in the example. Set the spacing as padding-left on the slides and the same amount spacing as negative margin-left on the container. See the screenshot:

A6A666A1-4C4C-4AFB-A18F-EF2E386449FE

Additionally, remove all other margins and paddings you’ve added when trying to achieve the spacing to get rid of unintended white space. This has nothing to do with Embla but it’s pure CSS related.

Best, David

davidjerleke commented 1 year ago

@haroldao did this help?

haroldao commented 1 year ago

No it didn’t:/. (The codepen is up to date btw)

davidjerleke commented 1 year ago

@haroldao I think this fixes the problem:

fix

Read more about the containScroll option here.

Best, David

haroldao commented 1 year ago

@haroldao I think this fixes the problem:

fix

Read more about the containScroll option here.

Best,

David

Ohhh yeah .... my bad 🤦🏽‍♂️! thank you (the codepen is updated)