So im working on a project for college, and the transition is not working on the dropdown nav bar. I tried changing the css code but it just seems to not work no matter what. I started a webpage just to see if I can do it here, but nope I was wrong. Maybe theres a problem with the ordering or something else, I just cant seem to figure. Been doing this for days and still no effect on that simple dropdown navbar and it drives me crazy.
When I click on the checkbox it should play a very minimalistic effect, but nothing. Heres the link for that new webpage, any help is appreciated!
But here is the code if you dont mind downloading:
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="1.css">
<title>Document</title>
</head>
<body>
<div class="div2">
</div>
<nav>
<input type="checkbox" id="navtoggle" class="navtoggle">
<label for="navtoggle"><img src="hamburger2.png" alt="ham" class="pic1" width="20"></label>
<div class="div1">
<ul>
<li><a href="2.html">First page</a></li>
<li><a href="2.html">Second page</a></li>
<li><a href="2.html">Third page</a></li>
</ul>
</div>
</nav>
</body>
</html>
CSS
body
{
background-color: brown;
margin: 0;
padding: 0;
position: relative;
height: 300px;
}
.pic1
{
position: absolute;
z-index: 10;
top: 18px;
left: 10px;
}
.div2
{
top:0;
position: absolute;
height: 50px;
width: 100%;
background-color: green;
}
.navtoggle
{
position: absolute;
top: 20px;
z-index: 4;
display: none;
}
.navtoggle:checked ~ .div1
{
height: max-content;
display: none;
transition: 1s;
}
.div1, ul
{
position: relative;
left: 50%;
width: 100%;
transform: translateX(-50%);
top: 50px;
background-color: yellowgreen;
}
ul
{
top: 0px;
display: block;
margin:0;
padding:0;
width: max-content;
}
li
{
list-style-type: none;
padding:10px 0 10px 0 ;
}
li a
{
color: brown;
text-decoration: none;
}
.div1 ul li a
{
position: relative;
text-decoration: none;
}
.div1 ul li a:hover
{
color:grey;
transition: 0.4s;
}