Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Navbar Wrapping on Mobile #23

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ <h2>Hackspace in the Heart of Vienna</h2>
</div>
</header>
<nav aria-label="Main Navigation">
<ul>
<li class="atomic"><img src="images/atomic.svg"
alt="Metalab Logo: a telephone booth in front of a Rutherford atomic model"></li>
<button class="nmenu-toggle" aria-label="Toggle Navigation" onclick="toggleNavbar()">☰</button>
<ul id="navbarMenu" class="navbar-menu">
<li class="atomic">
<img src="images/atomic.svg" alt="Metalab Logo: a telephone booth in front of a Rutherford atomic model">
</li>
<li><a href="#" class="active">Home</a></li>
<li><a href="rooms.html">Rooms</a></li>
<!-- <li><a href="events.html">Events</a></li> -->
Expand Down
63 changes: 59 additions & 4 deletions metalab.css
Original file line number Diff line number Diff line change
Expand Up @@ -193,25 +193,28 @@ header>.reducedmotion {
background-color: var(--color-3);
}

/* Navbar Styles */
nav {
position: sticky;
top: 0;
left: 0;
right: 0;
background-color: var(--color-5);
display: flex;
justify-content: center;
align-items: center;
justify-content: space-between;
box-shadow: 0 3px 3px black;
padding: 0.5em 1em;
z-index: 1000;
}

nav>ul {
nav > ul {
list-style-type: none;
margin: 0;
padding: 0;
display: flex;
align-items: center;

padding: 0.5em 1em;
justify-content: flex-start;
width: 100%;
max-width: var(--max-width);
flex-wrap: wrap;
Expand Down Expand Up @@ -253,6 +256,58 @@ nav .spacer {
flex-grow: 1;
}

/* Button Styling */
button.nmenu-toggle {
background: none;
border: none;
font-size: 2.5rem;
color: var(--color-1);
cursor: pointer;
padding: 0;
margin: 0;
line-height: 1;
display: flex;
justify-content: center;
align-items: center;
border-radius: 1em;
transition: background-color ease-in-out 0.2s;
}

button.nmenu-toggle::before {
display: none;
}

button.nmenu-toggle:hover {
color: var(--color-8);
}

@media (max-width: 768px) {
nav > ul {
display: none;
flex-direction: column;
background-color: var(--color-5);
position: absolute;
top: 3.5em;
left: 0;
width: 100%;
box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
z-index: 10;
}

button.nmenu-toggle {
display: block;
}

nav > ul.show {
display: flex;
}

nav > ul > li {
text-align: center;
margin: 0.5em 0;
}
}

main {
width: 100%;
display: flex;
Expand Down
7 changes: 7 additions & 0 deletions scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,10 @@ video.addEventListener('click', () => {
pausesymbol.style.display = 'none';
}
});

// NAVBAR TOGGLE FUNCTIONALITY

function toggleNavbar() {
const menu = document.querySelector('nav > ul');
menu.classList.toggle('show');
}