I use since severals years a simple horizontal css menu with submenu. I try to modify it to tranform in responsive.
Finally I change my basic horizontal Menu. And it's give that
<!DOCTYPE html>
<html>
<head>
<style>
body {
margin: 0;
}
.container {
display: inline-block;
cursor: pointer;
}
.bar1, .bar2, .bar3 {
width: 35px;
height: 5px;
background-color: #BDF1A5;
margin: 6px 0;
transition: 0.4s;
}
.change .bar1 {
-webkit-transform: rotate(-45deg) translate(-9px, 6px);
transform: rotate(-45deg) translate(-9px, 6px);
}
.change .bar2 {
opacity: 0;
}
.change .bar3 {
-webkit-transform: rotate(45deg) translate(-8px, -8px);
transform: rotate(45deg) translate(-8px, -8px);
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #534D4D;
}
li {
float: left;
}
li a {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
width: 180px;
}
li a:hover {
background-color: red;
}
li.dropdown {
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {
background-color: #f1f1f1;
}
.dropdown:hover .dropdown-content {
display: block;
}
li.icon {
display: none;
}
/*li:not(:first-child)*/
@media screen and (max-width:680px) {
ul.menu_deroulant li {
display: none;
}
ul.menu_deroulant li.icon {
float: right;
display: inline-block;
background-color: #534D4D;
padding: 5px;
}
ul.menu_deroulant.responsive {
position: relative;
}
ul.menu_deroulant.responsive li.icon {
position: absolute;
right: 0;
top: 0;
}
ul.menu_deroulant.responsive li {
float: none;
display: inline;
}
ul.menu_deroulant.responsive li a {
display: block;
text-align: left;
}
.dropdown-content {
position: absolute;
left: 208px;
top: 0;
bottom: 0;
}
}
</style>
</head>
<body>
<ul class="menu_deroulant" id="myTopnav">
<li><a class="active" href="#home">Home</a></li>
<li class="dropdown">
<a href="#">Réalisations</a>
<div class="dropdown-content">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</li>
<li><a href="#contact">Contact</a></li>
<li class="icon">
<div class="container" onclick="myFunction(this)">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
</div>
</li>
</ul>
<script>
function myFunction(y) {
y.classList.toggle("change");
var x = document.getElementById("myTopnav");
if (x.className === "menu_deroulant") {
x.className += " responsive";
} else {
x.className = "menu_deroulant";
}
}
</script>
</body>
</html>
And it's good. I let you my code to help you :-)