Witam. Znalazłem świetny poradnik dotyczący tego jak zrobić hamburger menu.
<!DOCTYPE html>
<html>
<head>
<title>Tutorial</title>
<link rel="stylesheet" type="text/css" href="main.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div class="nav">
<label for="toggle">☰</label>
<input type="checkbox" id="toggle"/>
<div class="menu">
<a href="#">Business</a>
<a href="#">Services</a>
<a href="#">Learn More</a>
<a href="#"><span>Free Trial</span></a>
</div>
</div>
</body>
</html>
html, body {
width: 100%;
height: 100%;
margin: 0;
}
html {
font-family: "helvetica neue", sans-serif;
}
.nav {
border-bottom: 1px solid #EAEAEB;
text-align: right;
height: 70px;
line-height: 70px;
}
.menu {
margin: 0 30px 0 0;
}
.menu a {
clear: right;
text-decoration: none;
color: gray;
margin: 0 10px;
line-height: 70px;
}
span {
color: #54D17A;
}
label {
margin: 0 40px 0 0;
font-size: 26px;
line-height: 70px;
display: none;
width: 26px;
float: right;
}
#toggle {
display: none;
}
@media only screen and (max-width: 500px) {
label {
display: block;
cursor: pointer;
}
.menu {
text-align: center;
width: 100%;
display: none;
}
.menu a {
display: block;
border-bottom: 1px solid #EAEAEB;
margin: 0;
}
#toggle:checked + .menu {
display: block;
}
}
Niestety jedyny problem dotyczy tego, że gdy wybierze się jedną z opcji z rozwiniętego menu, nie znika nam ono
Jakby któs pomógł mi zniwelować ten problem używając jquery,jsa czy czegokolwiek byłbym bardzo wdzięczny.
Pozdrawiam
Edit: Link do poradnika https://www.youtube.com/watch?v=xMTs8tAapnQ