Design comparison
Solution retrospective
I have had issues with aligning the background pattern on both mobile and desktop version, any tips would help :)
Also, the down and up arrows are not working perfectly due to something I am missing on the JavaScript code I believe. How can I fix it?
Thank you in advance!
Community feedback
- @paiputPosted over 3 years ago
You could create different functions that use a for of loop to iterate through:
- each questions' title
- each questions' arrow
- each questions' paragraph
You could create classes in CSS, and, in those for loops, remove or add those classes to each
<div class="line">
elements.I would use classes for all the titles, arrows, and paragraphs. This would be useful for example with the arrows, because you could use just one image, and when you click on the question or on the arrow, you add that image a class like this:
.rotate-arrow {
transform: rotate(180deg); transition: transform ease .5s;}`And in the JS, you could do something like this:
const = document.querySelectorAll('.titleArrows'); // In your case your class is '.straight' I think function rotateArrow(targetElement) { for (arrow of titleArrows) { arrow.classList.remove('rotate-arrow'); } targetElement.classList.add('rotate-arrow'); }
After created those functions, you should create an eventListener that detects if you clicked on a question title, or on an arrow. You could do something like this:
// I made it like this const box= document.querySelector('.box'); container.addEventListener('click', (e) => { if (e.target.classList.contains('questionTitle')) { rotateArrow(e.target.firstElementChild); } else if (e.target.classList.contains('titleArrows')) { rotateArrow(e.target); } }
The example above is just to give you an idea. Consider that the this example cannot be applied as is in your html because the layout is probably different.
I hope this example has been helpful for you.
1@basakulcayPosted over 3 years agoThank you @paiput I will try applying these suggestions.
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord