Es will nicht so richtig klappen
Hab das Tut genau befolgt diese hier aber seht selbst . Hab es mal hochgeladen
HTML
HTML
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="css/styles.css">
<script type="text/javascript" src="js/script.js" ></script>
<title>new Beginning</title>
</head>
<body>
<header>
<nav>
<div class="brand">Michael Schlegel</div>
<a href="#" class="toggle-button">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span></a>
<div class="list-container">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Fischen</a></li>
<li><a href="#">Kulinarisches</a></li>
<li><a href="#">Galerie</a></li>
<li><a href="#">Datenschutz</a></li>
</ul>
</div>
</nav>
</header>
<main></main>
<footer></footer>
</body>
</html>
Alles anzeigen
CSS
Code
*{
margin: 0;
padding:0;
}
html{
height: 100%;
}
body{
height: 100%;
background-color: whitesmoke;
}
nav{
min-height: 80px;
display: flex;
justify-content: space-between;
align-items: center;
background-color: rgb(56, 54, 54);
color: white;
}
.brand{
margin: 20px;
font-size: 1.2em;
font-weight: bold;
color: aqua;
}
nav ul{
display:flex
}
nav ul li{
height: 100%;
padding: 30px;
list-style-type: none;
border-bottom: 4px solid rgb(42,42,42);
}
nav ul li:hover{
border-bottom: 4px solid purple;
}
nav ul li a{
color: white;
text-decoration: none;
font-size: 1em;
font-family: sans-serif;
}
.toggle-button{
position: absolute;
top: 25px;
right: 25px;
display: flex;
flex-direction: column;
justify-content: space-between;
width: 30px;
height:23px;
}
.toggle-button .bar{
height:4px;
width:100%;
background-color: white;
border-radius: 100px;
}
@media(max-width:750px){
.list-container{
display: flex;
width: 100%
}
.toggle-button{
display: flex;
}
}
nav{
flex-direction: column;
align-items: 100%;
}
.list-container ul{
flex-direction: column;
width: 100%;
}
.list-container li{
text-align: center;
}
.list-container.active{
display: flex;
}
Alles anzeigen
Javascript
Code
const toggleButton = document.getElementsByClassName("toggle-button")[0]
const listContainer = document.getElementsByClassName("list-container")[0]
toggleButton.addEventListener("click",() =>{
listContainer.classList.toggle("active")
})
Das waren sechs Stunden tippen und testen
Ich finde auch den Fehler nicht.
Gruß und gute nacht