/    Sign up×
Community /Pin to ProfileBookmark

JavaScript Carousel

Hi, I am trying to learn how to build a carousel. But I got into a problem.
I managed to make the carousel to work. Although the second and 3rd img are invisible and I don’t know why. JavaScript seems to be alright. Is there a CSS problem?

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumJul 22.2019 — Please post the code or a codepen or a link to the page.
Copy linkTweet thisAlerts:
@codyhillauthorJul 22.2019 — @Sempervivum#1606593 https://codepen.io/raul-rogojan/pen/BXoWBq?editors=0010 MY BAD!!
Copy linkTweet thisAlerts:
@codyhillauthorJul 22.2019 — @RaulRogojan#1606590 THE CODE HERE: https://codepen.io/raul-rogojan/pen/BXoWBq?editors=0010
Copy linkTweet thisAlerts:
@SempervivumJul 22.2019 — You arranged the slides one upon the other by absolute positioning. However your code indicates that you intend to make a sliding transition, not fading.

Remove the absolute positioning and arrange the slides side by side through `display: flex;`. Set the width of the ul to 300%. This is a rought improvement:

https://codepen.io/Sempervivum/pen/BXowwK

Still a lot to optimise ...
Copy linkTweet thisAlerts:
@codyhillauthorJul 22.2019 — @Sempervivum#1606598 I wanted to position them next to each other with javaScript. That's why I wrote this
const setSlidePosition = (slide, index) => {
slide.style.left = slideWidth * index + 'px';
};
. I will play with the positioning and I'll come back if it doesn't work.
Copy linkTweet thisAlerts:
@SempervivumJul 22.2019 — You forgot to insert the code ;-)
Copy linkTweet thisAlerts:
@codyhillauthorJul 22.2019 — @Sempervivum#1606600 Yeah, I did it right after. I am doing a bunch of stuff rn, sorry haha
Copy linkTweet thisAlerts:
@codyhillauthorJul 22.2019 — @Sempervivum#1606600 Fixed the issue. The problem was that the li did not have a width and height. The problem is that I don't know how to make it jump to the first img after the last one.
×

Success!

Help @codyhill spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...