updated responsive navbar
This commit is contained in:
parent
2e0b4626c8
commit
b771d105da
3 changed files with 180 additions and 8 deletions
|
@ -51,7 +51,7 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<div class="logo">
|
<div class="logo">
|
||||||
<a href="#" class="menu-trigger"><i class='bx bx-menu'></i></a>
|
<a href="#" class="menu-trigger" open-btn><i class='bx bx-menu'></i></a>
|
||||||
<a href=""><span>Blood</span> Bank</a>
|
<a href=""><span>Blood</span> Bank</a>
|
||||||
<img src="images/logo-1.png" alt="">
|
<img src="images/logo-1.png" alt="">
|
||||||
</div>
|
</div>
|
||||||
|
@ -61,14 +61,14 @@
|
||||||
<li><a href="#"><span>Donate</span><i class='bx bx-chevron-down' ></i></a>
|
<li><a href="#"><span>Donate</span><i class='bx bx-chevron-down' ></i></a>
|
||||||
<ul class="submenu">
|
<ul class="submenu">
|
||||||
<li><a href="">Donate Blood</a></li>
|
<li><a href="">Donate Blood</a></li>
|
||||||
<li><a href="">Donation types</a></li>
|
<li><a href="">Donation Types</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#"><span>Learn</span><i class='bx bx-chevron-down' ></i></a>
|
<li><a href="#"><span>Learn</span><i class='bx bx-chevron-down' ></i></a>
|
||||||
<ul class="submenu">
|
<ul class="submenu">
|
||||||
<li><a href="">Blood types</a></li>
|
<li><a href="">Blood Types</a></li>
|
||||||
<li><a href="">First time Blood Doner</a></li>
|
<li><a href="">First Time Blood Doner</a></li>
|
||||||
<li><a href="">Scientific research</a></li>
|
<li><a href="">Scientific Research</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#"><span>Support</span><i class='bx bx-chevron-down' ></i></a>
|
<li><a href="#"><span>Support</span><i class='bx bx-chevron-down' ></i></a>
|
||||||
|
@ -79,9 +79,9 @@
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#"><span>Service</span><i class='bx bx-chevron-down' ></i></a>
|
<li><a href="#"><span>Service</span><i class='bx bx-chevron-down' ></i></a>
|
||||||
<ul class="submenu">
|
<ul class="submenu">
|
||||||
<li><a href="">Laboratory services</a></li>
|
<li><a href="">Laboratory Services</a></li>
|
||||||
<li><a href="">Clinical apheresis services </a></li>
|
<li><a href="">Clinical Apheresis Services </a></li>
|
||||||
<li><a href="">Medical consultation</a></li>
|
<li><a href="">Medical Consultation</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -95,6 +95,49 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
<main></main>
|
||||||
|
<footer></footer>
|
||||||
|
|
||||||
|
<div class="overlay" data-overlay></div>
|
||||||
|
|
||||||
|
<nav class="mobile" data-show>
|
||||||
|
<a href="#" class="close-trigger" close-btn><i class='bx bx-x-circle' ></i></a>
|
||||||
|
<ul>
|
||||||
|
<li><a href="">Home</a></li>
|
||||||
|
<li><a href="">Donate</a>
|
||||||
|
<span class="sub-trigger"><i class='bx bx-chevron-down' ></i></span>
|
||||||
|
<ul class="submenu">
|
||||||
|
<li><a href="">Donate Blood</a></li>
|
||||||
|
<li><a href="">Donation Types</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li><a href="">Learn</a>
|
||||||
|
<span class="sub-trigger"><i class='bx bx-chevron-down' ></i></span>
|
||||||
|
<ul class="submenu">
|
||||||
|
<li><a href="">Blood Types</a></li>
|
||||||
|
<li><a href="">First Time Blood Doner</a></li>
|
||||||
|
<li><a href="">Scientific Research</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li><a href="">Support</a>
|
||||||
|
<span class="sub-trigger"><i class='bx bx-chevron-down' ></i></span>
|
||||||
|
<ul class="submenu">
|
||||||
|
<li><a href="">Volunteer</a></li>
|
||||||
|
<li><a href="">Partnerships</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li><a href="">Service</a>
|
||||||
|
<span class="sub-trigger"><i class='bx bx-chevron-down' ></i></span>
|
||||||
|
<ul class="submenu">
|
||||||
|
<li><a href="">Laboratory Services</a></li>
|
||||||
|
<li><a href="">Clinical Apheresis Services </a></li>
|
||||||
|
<li><a href="">Medical Consultation</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script src="main.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -0,0 +1,17 @@
|
||||||
|
const menuTrigger = document.querySelectorAll('[open-btn]');
|
||||||
|
const mobileMenu = document.querySelectorAll('[data-show]');
|
||||||
|
const closeTrigger = document.querySelectorAll('[close-btn]');
|
||||||
|
const overlay = document.querySelector('[data-overlay]');
|
||||||
|
|
||||||
|
for (let x = 0; x < menuTrigger.length; x++){
|
||||||
|
const closeMenu = function(){
|
||||||
|
mobileMenu[x].classList.remove('active');
|
||||||
|
overlay.classList.remove('active');
|
||||||
|
}
|
||||||
|
menuTrigger[x].addEventListener('click', function() {
|
||||||
|
mobileMenu[x].classList.add('active');
|
||||||
|
overlay.classList.add('active');
|
||||||
|
})
|
||||||
|
closeTrigger[x].addEventListener('click', closeMenu);
|
||||||
|
overlay.addEventListener('click', closeMenu)
|
||||||
|
}
|
|
@ -102,6 +102,10 @@ header li a:hover{
|
||||||
color: #D22B2B;
|
color: #D22B2B;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.header-top, .header-main nav > ul{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
/*-------- header-main ---------*/
|
/*-------- header-main ---------*/
|
||||||
.header-main .container .wrap .logo img{
|
.header-main .container .wrap .logo img{
|
||||||
width: 60px;
|
width: 60px;
|
||||||
|
@ -143,10 +147,118 @@ header li a:hover{
|
||||||
.header-main :where(nav > ul > li >a span, .logo){
|
.header-main :where(nav > ul > li >a span, .logo){
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
/*---------- mobile menu ----------*/
|
||||||
|
.overlay{
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100vh;
|
||||||
|
background-color: rgb(0 0 0 /50%);
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 15px;
|
||||||
|
transition: 0.5s ease;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
.overlay.active{
|
||||||
|
opacity: 1;
|
||||||
|
pointer-events: all;
|
||||||
|
}
|
||||||
|
nav.mobile{
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 350px;
|
||||||
|
height: 100%;
|
||||||
|
max-width: calc(100vw -60px);
|
||||||
|
padding: 30px;
|
||||||
|
background-color: whitesmoke;
|
||||||
|
z-index: 1000;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
left: -100%;
|
||||||
|
visibility: hidden;
|
||||||
|
transition: 0.5s ease;
|
||||||
|
}
|
||||||
|
nav.mobile.active{
|
||||||
|
left: 0;
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
nav.mobile > ul > li{
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
nav.mobile > ul > li > a{
|
||||||
|
position: relative;
|
||||||
|
display: block;
|
||||||
|
padding: 13px 0;
|
||||||
|
}
|
||||||
|
.close-trigger{
|
||||||
|
font-size: 22px;
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
line-height: 40px;
|
||||||
|
text-align: center;
|
||||||
|
transition: color 0.3s;
|
||||||
|
}
|
||||||
|
.close-trigger:hover{
|
||||||
|
color: #D22B2B;
|
||||||
|
}
|
||||||
|
nav.mobile .close-trigger{
|
||||||
|
position: absolute;
|
||||||
|
right: -40px;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
nav.mobile > ul{
|
||||||
|
overflow-y: auto;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
}
|
||||||
|
nav.mobile > ul >li > span{
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 40px;
|
||||||
|
height: 55px;
|
||||||
|
font-size: 22px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: color 0.3s;
|
||||||
|
}
|
||||||
|
nav.mobile > ul >li > span:hover{
|
||||||
|
color: #D22B2B;
|
||||||
|
}
|
||||||
|
nav.mobile .submenu{
|
||||||
|
height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
nav.mobile .submenu a{
|
||||||
|
color: #E34234;
|
||||||
|
padding-left: 15px;
|
||||||
|
transition: color 0.3s;
|
||||||
|
}
|
||||||
|
nav.mobile .submenu a:hover{
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@media only screen and (min-width:992px){
|
@media only screen and (min-width:992px){
|
||||||
|
.header-main nav > ul{
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
.header-top{
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
.header-main .menu-trigger{
|
.header-main .menu-trigger{
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue