Click here to Skip to main content
15,922,015 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have found code from "CodePen" named "vanilla js carousel" (https://codepen.io/ekeric13/pen/wKOwmg[^]). But I can't figure out how to create vertical infinite carousel. Please, give some ideas or if you already has code, I wish you would share it with me.

P.S: I don't want to use any plugins or libraries.

What I have tried:

change top/bottom by height.
Posted
Updated 6-May-21 2:58am

1 solution

If you don't want to use any plugins or libraries and stick to vanilla JS then you'll need to repurpose the code that you've provided. If you think logically about what you're asking, the horizontal carousel depends on the container width and the child elements widths, and then moves them based on the left position.

So to translate that into vertical, look at the example code you already have and then translate the requirements. The vertical carousel depends on the container height and the child elements heights, and then moves them based on the top position.

Just a quick Google found for me: html - How to create a vertical carousel using plain JavaScript and CSS - Stack Overflow[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900