Design comparison
Solution retrospective
How would you do a drop-down menu using only HTML and CSS?
Community feedback
- @Chanda-AbdulPosted over 1 year ago
👋 Your Sunnyside landing page looks great!
Here are two approaches you could use to create a dropdown menu using just HTML and CSS:
-
Using the
:target
pseudo-class: This method involves defining targets within your HTML and using CSS to show/hide content based on the target's ID. By leveraging the:target
selector, you can create a dropdown effect when certain elements are clicked or targeted. https://css-tricks.com/off-canvas-menu-with-css-target/ -
Using a form input checkbox styled as a menu: This method utilizes a checkbox
<input>
element within a form and applies CSS styles to make it appear like a menu. By toggling the checkbox's checked state, you can control the visibility of the dropdown menu through CSS selectors and transitions. https://css-tricks.com/the-checkbox-hack/
I hope these suggestions help!. If you have any further questions, feel free to ask!
Happy coding!
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