Design comparison
Solution retrospective
Hello I would like if you could help me especially in the JS code, is there any more practical way to make the display of the submenus, change the image of the arrow, and all the HTML and CSS tips that you can give me I appreciate it very much.
Community feedback
- @DavidMorgadePosted about 2 years ago
Hello Stalin, congrats on finishing the challenge, amazing job!
Let me try to answer your questions as much as I can.
For the submenus, you could have used
height: 0
as default and then increase the height with a CSS class added on click and animate it withtransition: height 0.5s linear
, butdisplay: none
also does the job!In the case of the arrow image, you don't even need to use another image, you can create a CSS class with
transform
and add it dinamically with JS, something like this:CSS:
.rotate { transform: rotate(180deg); transition: transform 0.5s linear; }
JS:
const openSubMenu = (submenu) => { submenu.addEventListener('click', () => { iconchange.classList.toggle('rotate'); }) } openSubMenu(openCompany)
Hope my feedback helps you, if you have any question, don't hesitate to ask!
Marked as helpful0
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