I am working on a website right now but I am having trouble getting simple CSS to do what I want it to do. I am trying to create a dropdown menu that becomes visible when hovered over on mobile. I have the dropdown menu already created and hidden, and I have the hamburger icon created as well.
I have tried using JavaScript but I literally hate JavaScript. I don't even want to bring that up haha. After I realized I was getting nowhere with JavaScript, I figured I should be able to do it using only CSS. I have re-written the code several times thinking I made a typo that I cannot find.
@media screen and (max-width:768px){
.topNav{
position: absolute;
right: 0px;
height: 92vh;
top: 10vh;
width: 300px;
background-color: #001d4c;
z-index: 1;
display:none;
flex-direction: column;
align-items: center;
width: 40%;
transition: transform 0.5s ease-in;
}
.burger{
display:block;
}
.burger:hover .topNav {
display:flex;
}
}
I expect to be able to have a dropdown menu when the burger is clicked on. The burger btw is just 3 horizontal lines with nothing special attached to them. However, when i try to click on it or hover over it, nothing happens.
When I change the display on the topNav class to flex, it shows the menu perfectly fine, but it is not wanting to show when I hide it until i hover.