Responsive navbar
parent
7fdf6dc0b5
commit
3aaa0b25e8
|
@ -0,0 +1,98 @@
|
|||
body {
|
||||
background: url("https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcR_rULCgxJV4_821sMNFp56GPMInvkG3zW_14WQ6z0_BPfY1pkaHrJ4stu6");
|
||||
background-size: 100vw 100vh;
|
||||
}
|
||||
@import url('https://fonts.googleapis.com/css?family=Montserrat:400,500,600,700&display=swap');
|
||||
*{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
font-family: 'Montserrat',sans-serif;
|
||||
}
|
||||
nav{
|
||||
background: #151515;
|
||||
padding: 5px 40px;
|
||||
}
|
||||
nav ul{
|
||||
list-style: none;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
nav ul li{
|
||||
padding: 15px 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
nav ul li.items{
|
||||
position: relative;
|
||||
width: auto;
|
||||
margin: 0 16px;
|
||||
text-align: center;
|
||||
order: 3;
|
||||
}
|
||||
nav ul li.items:after{
|
||||
position: absolute;
|
||||
content: '';
|
||||
left: 0;
|
||||
bottom: 5px;
|
||||
height: 2px;
|
||||
width: 100%;
|
||||
background: #33ffff;
|
||||
opacity: 0;
|
||||
transition: all 0.2s linear;
|
||||
}
|
||||
nav ul li.items:hover:after{
|
||||
opacity: 1;
|
||||
bottom: 8px;
|
||||
}
|
||||
nav ul li.logo{
|
||||
flex: 1;
|
||||
color: white;
|
||||
font-size: 23px;
|
||||
font-weight: 600;
|
||||
cursor: default;
|
||||
user-select: none;
|
||||
}
|
||||
nav ul li a{
|
||||
color: white;
|
||||
font-size: 18px;
|
||||
text-decoration: none;
|
||||
transition: .4s;
|
||||
}
|
||||
nav ul li:hover a{
|
||||
color: cyan;
|
||||
}
|
||||
nav ul li i{
|
||||
font-size: 23px;
|
||||
}
|
||||
nav ul li.btn{
|
||||
display: none;
|
||||
}
|
||||
nav ul li.btn.hide i:before{
|
||||
content: '\f00d';
|
||||
}
|
||||
@media all and (max-width: 900px){
|
||||
nav{
|
||||
padding: 5px 30px;
|
||||
}
|
||||
nav ul li.items{
|
||||
width: 100%;
|
||||
display: none;
|
||||
}
|
||||
nav ul li.items.show{
|
||||
display: block;
|
||||
}
|
||||
nav ul li.btn{
|
||||
display: block;
|
||||
}
|
||||
nav ul li.items:hover{
|
||||
border-radius: 5px;
|
||||
box-shadow: inset 0 0 5px #33ffff,
|
||||
inset 0 0 10px #66ffff;
|
||||
}
|
||||
nav ul li.items:hover:after{
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
/* Created by Sahil Verma*/
|
|
@ -0,0 +1,36 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
<!-- Created By Sahil Verma
|
||||
|
||||
CAUTION: Don't copy without my permission -->
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Responsive Navigation Bar</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
|
||||
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
<body>
|
||||
<nav>
|
||||
<ul>
|
||||
<li class="logo">DesignX</li>
|
||||
<li class="items"><a href="#">Home</a></li>
|
||||
<li class="items"><a href="#">About</a></li>
|
||||
<li class="items"><a href="#">Blogs</a></li>
|
||||
<li class="items"><a href="#">Contact</a></li>
|
||||
<li class="items"><a href="#">Feedback</a></li>
|
||||
<li class="btn"><a href="#"><i class="fas fa-bars"></i></a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$('.btn').click(function(){
|
||||
$('.items').toggleClass("show");
|
||||
$('ul li').toggleClass("hide");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue