Skip to content

Commit

Permalink
Merge pull request #781 from aryansharma220/responsiveHam
Browse files Browse the repository at this point in the history
Fixes: Navbar Hamburger not responsive #551
  • Loading branch information
huamanraj authored May 23, 2024
2 parents 44cef83 + 57bc5d5 commit d417f6f
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 11 deletions.
130 changes: 125 additions & 5 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ body {
max-height: 330px;
}
} */

.navbar-list{
display: flex;
justify-content: center; /* Center align the navbar items */
Expand All @@ -541,23 +542,45 @@ body {
}

.navbar-link:is(:hover, :focus) {
color: hsl(357, 37%, 62%);
color: var(--old-rose);
}

.dropdown-menu {
display: none;
/* display: none;
position: absolute;
top: calc(100% + 5px);
left: 0;
background-color: var(--white);
padding: 10px;
border-radius: 5px;
border-radius: 5px; */
display: none;
position: absolute;
background-color: #fff;
box-shadow: 0 8px 16px rgba(0,0,0,0.2);
z-index: 1;
transition: all 0.3s ease;
top: 100%;
}

.dropdown-item {
margin-top: 5px;
}

.dropdown-menu-list {
list-style: none;
margin: 0;
padding: 0;
}

.dropdown-menu-item {
padding: 12px 16px;
}

.dropdown-menu-item a {
text-decoration: none;
color: #000;
}

.dropdown-item:first-child {
margin-top: 0;
}
Expand All @@ -572,11 +595,108 @@ body {

.navbar-item.dropdown:hover .dropdown-menu {
display: block;
} */


.nav-toggle-btn {
font-size: 40px;
color: var(--charcoal);
}

.nav-toggle-btn ion-icon {
--ionicon-stroke-width: 20px;
}

.nav-toggle-btn.active .open,
.nav-toggle-btn .close {
display: none;
}

.nav-toggle-btn .open,
.nav-toggle-btn.active .close {
display: block;
}

.navbar {
border: 1px solid #000;
display: inline-block;
position: absolute;
top: 100%;
left: 0;
width: 100%;
background-color: var(--white);
padding-inline: 15px;
max-height: 0;
overflow: hidden;
visibility: hidden;
transition: 0.25s var(--cubic-out);
}

.navbar.active {
max-height: 387px;
visibility: visible;
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
transition-duration: 0.5s;
overflow-y: scroll;
}

.navbar-list {
display: flex;
justify-content: center;
align-items: center;
margin: 0;
padding: 0;
}

.navbar-item {
margin: 0 10px;
padding: 0;
}

.navbar-link {
position: relative;
color: var(--charcoal);
padding: 8px 12px;
line-height: 2;
transition: var(--transition-1);
}

.navbar-link:is(:hover, :focus) {
color: var(--old-rose);
}

/* Adjust the position of the dropdown menu */
.dropdown-menu {
top: 100%; /* Position below the navbar item */
display: none;
position: absolute;
background-color: #fff;
box-shadow: 0 8px 16px rgba(0,0,0,0.2);
z-index: 1;
transition: all 0.3s ease;
top: 100%;
}

.dropdown-menu-list {
list-style: none;
margin: 0;
padding: 0;
}

.dropdown-menu-item {
padding: 12px 16px;
}

.dropdown-menu-item a {
text-decoration: none;
color: #000;
}

.dropdown-menu.active {
display: block;
}

.navbar-item.dropdown {
position: relative;
}


Expand Down
16 changes: 16 additions & 0 deletions assets/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,19 @@ function validateAndConnect() {
document.getElementById('yourPrice').value='';
}
}


function toggleMoreDropdown(event) {
event.preventDefault();
const moreDropdown = document.getElementById('more-dropdown');
const dropdownMenu = document.getElementById('dropdown-menu');
const moreLink = document.getElementById('more-link');

if (dropdownMenu.style.display === "block") {
dropdownMenu.style.display = "none";
moreLink.style.display = "block";
} else {
dropdownMenu.style.display = "block";
moreLink.style.display = "none";
}
}
11 changes: 5 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@
<a href="./assets/html/login.html" class="navbar-link">Login/Signup</a>
</li>

<li class="navbar-item dropdown">
<a href="#" class="navbar-link">More <i class="ri-arrow-down-s-line"></i></a>
<div class="dropdown-menu">
<li class="navbar-item dropdown" id="more-dropdown">
<a href="#" class="navbar-link" id="more-link" onclick="toggleMoreDropdown(event)">More <i class="ri-arrow-down-s-line"></i></a>
<div class="dropdown-menu" id="dropdown-menu">
<ul class="dropdown-menu-list">
<li class="dropdown-menu-item">
<a href="#chapters" onclick="lenis.scrollTo('#chapters')" class="navbar-link" data-nav-link><i class="ri-medal-fill"></i> Literary Realms</a>
Expand All @@ -137,9 +137,8 @@
</li>
</ul>
</div>

<li>

</li>

<div class="switch-container">
<input type="checkbox" id="switch" class="switch-checkbox">
<label for="switch" class="switch-label">
Expand Down

0 comments on commit d417f6f

Please sign in to comment.