Skip to content

[Help]: 1px of previous slide showing for some slides #1181

Closed Answered by pbowyer
pbowyer asked this question in Help
Discussion options

You must be logged in to vote

And just like that, I think I've found a fix for this particular use-case: https://developer.mozilla.org/en-US/docs/Web/CSS/round.

Thanks to CSS improvements last year there's the round() function. As I have the last slide hanging out of the viewport, I can round the widths of my slides to the nearest pixel and this won't cause me any problems. The specific change I made is:

.embla__slide {
  /* This is the fix - round the size to a whole pixel */
  flex: 0 0 round(var(--slide-size), 1px);
}

Now no white lines messing up my design 😀 Many thanks for your help in identifying the problem!

Demo of the fix: https://codesandbox.io/p/devbox/embla-carousel-generator-vanilla-forked-x233fv

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@davidjerleke
Comment options

@pbowyer
Comment options

@davidjerleke
Comment options

Answer selected by davidjerleke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
resolved This issue is resolved question Question about how to achieve something
2 participants