Ask coding questions

← Back to all posts
How do i implement a drop down menu?
Pizzaz4me

So, below the button "projects", I tried to create a drop down menu based on the display and hover function, but it doesn't work. How do I make it so that when i click or hover on the button "Projects", the two links below appear?

Answered by xfinnbar [earned 5 cycles]
View Answer
Voters
Pizzaz4me
Comments
hotnewtop
xfinnbar

Make a div with a class dropdown with a button and some items inside it:

Use the :focus-within pseudo-class to detect button clicks in CSS:

Pizzaz4me

I tried your code, and it doesn't work @xfinnbar

xfinnbar

@Pizzaz4me edited, try it again

Pizzaz4me

still doesn't seem to work. Does it work for you? @xfinnbar

xfinnbar

@Pizzaz4me for real this time, it's fixed

Pizzaz4me

THANK YOU @xfinnbar