We would like to know how to create Responsive navigation dropdown mobile.
<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
body {<!--from w ww . j av a 2 s. com-->
margin: 0;
line-height: 1em;
}
ul {
margin: 0;
padding: 0;
list-style: none;
overflow: hidden;;
background-color: #666;
}
ul .btn {
display: none;
cursor: pointer;
}
ul li {
float: left;
}
ul li a {
display: block;
padding: 15px 0 15px 20px;
text-decoration: none;
color: #bbb;
}
ul li a:hover {
color: #fff;
}
@media ( max-width : 30em) {
ul li {
float: none;
}
ul .btn {
display: block;
}
ul .menu li a {
padding: 0px 20px 10px 20px;
}
ul .menu {
display: none;
}
ul li:hover .menu {
display: block;
}
}
</style>
</head>
<body>
<ul class="nav">
<li><a class="btn">☰</a>
<ul class="menu">
<li><a href="">Home</a></li>
<li><a href="">Portfolio</a></li>
<li><a href="">Contact</a></li>
</ul></li>
</ul>
</body>
</html>
The code above is rendered as follows: