Design comparison
Solution retrospective
I was unable to toggle the classList of a previousElementSibling. Please, check out the 'script.js' section for more info. Thanks.
Community feedback
- @StrocsPosted almost 2 years ago
Hi @shinaeli, I was looking on your code and found your problem.
previousElementSibling is working just fine, your problem is with css selectors specificity:
Change class selector + type selector (.compo h3) to a type selector (h3), this is because a class + type selector will have high priority over just a type selector, or class selector. (this is not the best solution, always is better use a class selector for every element)
h3 { padding: 5px; background-color: hsl(25, 47%, 15%); color: #fff; font-size: 12px; border-radius: 2px; margin-bottom: 5px; text-align: center; display: none; }
This is a great article for learn css selector specificity: Importance of CSS Specificity and its best practices
Hope this helps you! have a nice code day 😀
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