[Help]: How can I make a Card Carousel #361
-
Hi all, I was wondering how I could make a card carousel, similar to this: <div className="overflow-hidden bg-green-700" ref={emblaRef}>
<div className="flex gap-5 pt-6 bg-red-600">
{props.data.map((v, i) => (
<div className="group relative ml-10 h-56 w-40 overflow-hidden rounded-xl" >
<Image
src="/ghandi.png" //{v.hero}
layout="fill"
className="z-0 rounded-l-2xl object-cover object-center transition duration-[2s] ease-in-out group-hover:scale-110"
alt="Image the of game"
quality={90}
priority={false}
/>
<div className="absolute bottom-0 left-0 right-0 rounded-b-xl bg-gradient-to-t from-black via-black/70 to-transparent px-2 pt-3 pb-2">
<h3 className="lines-2 mb-1 w-36 pb-[0.05rem] text-2xl font-semibold leading-none text-gray-50">
Title
</h3>
<div className="flex items-center text-xs text-gray-100">
<p className="">{/*v.downloads*/}1 k</p>
<ArrowDownTrayIcon className="ml-1.5 mr-2 h-4 w-4" /> •
<span className="ml-2"></span>
<StarFilledIcon className="h-3 w-3 text-yellow-500" />
<StarFilledIcon className="h-3 w-3 text-yellow-500" />
<StarFilledIcon className="h-3 w-3 text-yellow-500" />
<StarFilledIcon className="h-3 w-3 text-yellow-500" />
<StarIcon className="h-3 w-3" />
</div>
</div>
</div>
))}
</div>
</div> If I remove If Embla carousel doesn't support these features, I can probably just code them myself using a scrollbar, some arrows, and just scrolling a bit to the left, but I have to imagine embla has a better way of doing this. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @quick007, Thanks for your question. There's a lot of CSS going on in your code example so I don't know if that's affecting anything in unintended ways. What version are you using? And you didn't share what
The alignment isn't weird. It's the default setup for Embla which will center {
containScroll: 'trimSnaps',
}
Then you should group your slides. Try using: {
slidesToScroll: 'auto' // note that the 'auto' vaule is only available from version 7 and up
} So your options should be set to: {
containScroll: 'trimSnaps',
slidesToScroll: 'auto'
} Read more about these options here: I hope this gets you on the right track. Best, |
Beta Was this translation helpful? Give feedback.
Hi @quick007,
Thanks for your question. There's a lot of CSS going on in your code example so I don't know if that's affecting anything in unintended ways. What version are you using? And you didn't share what
options
you're using? Should the carousel loop or not?The alignment isn't weird. It's the default setup for Embla which will center
align
the scroll snaps. If you want to clear leading and trailing space use the following option:Then you should group your slides. Try using: