From 35bed4012935b2ce8dcc5cb7e2a362dc0d953812 Mon Sep 17 00:00:00 2001 From: blake Date: Wed, 1 Oct 2025 16:52:57 -0500 Subject: [PATCH] Mobile navigation --- css/queries.css | 53 +++++++++++++++++++++++++++++++++++++++++++++ css/style.css | 26 ++++++++++++++++++++-- img/icons/close.svg | 42 +++++++++++++++++++++++++++++++++++ img/icons/menu.svg | 42 +++++++++++++++++++++++++++++++++++ index.html | 40 ++++++++++++++++++++++++---------- script.js | 9 ++++++++ 6 files changed, 199 insertions(+), 13 deletions(-) create mode 100644 img/icons/close.svg create mode 100644 img/icons/menu.svg diff --git a/css/queries.css b/css/queries.css index 8138e71..91e16b5 100644 --- a/css/queries.css +++ b/css/queries.css @@ -57,6 +57,50 @@ .contact-grid { gap: 0; } + + .btn-mobile-nav { + display: block; + z-index: 1000; + } + + .nav-links { + background-color: rgb(11, 21, 50, 0.9); + position: absolute; + top: 0; + right: 0; + width: 30%; + height: 40vh; + transform: translateX(100%); + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + border-bottom-left-radius: 100px; + transition: all 0.4s ease-in; + + opacity: 0; + pointer-events: none; + visibility: hidden; + } + + .nav-open .nav-links { + opacity: 1; + pointer-events: auto; + visibility: visible; + transform: translateX(0); + } + + .nav-open .icon-mobile-nav[name="close"] { + display: block; + } + + .nav-open .icon-mobile-nav[name="open"] { + display: none; + } + + .main-nav-link { + font-size: 3rem; + } } @media (max-width: 47em) { @@ -102,6 +146,9 @@ .contact-img { grid-row: 1; } + .nav-links { + width: 40%; + } } @media (max-width: 38em) { @@ -111,6 +158,9 @@ .hero { max-width: 90%; } + .nav-links { + width: 50%; + } } @media (max-width: 31em) { @@ -136,4 +186,7 @@ .heading-sub { max-width: 80%; } + .nav-links { + width: 60%; + } } diff --git a/css/style.css b/css/style.css index d504bd6..7083b7a 100644 --- a/css/style.css +++ b/css/style.css @@ -50,6 +50,7 @@ html { /* font-size: 10px; */ font-size: 62.5%; scroll-behavior: smooth; + overflow-x: hidden; } body { @@ -59,6 +60,11 @@ body { color: #fff; background-color: #0b1532; font-size: 2rem; + overflow-x: hidden; +} + +.header { + position: relative; } .nav { @@ -103,10 +109,26 @@ body { align-items: center; } -.rocket-icon { - max-width: 4rem; +.btn-mobile-nav { + border: none; + background: none; + cursor: pointer; + display: none; } +.icon-mobile-nav { + height: 5rem; + width: 5rem; +} + +.icon-mobile-nav[name="close"] { + display: none; +} + +/* .rocket-icon { + max-width: 4rem; +} */ + .main-nav-link.nav-btn:link, .nav-btn:visited { transition: all 0.3s; diff --git a/img/icons/close.svg b/img/icons/close.svg new file mode 100644 index 0000000..4bdc422 --- /dev/null +++ b/img/icons/close.svg @@ -0,0 +1,42 @@ + + + + + + diff --git a/img/icons/menu.svg b/img/icons/menu.svg new file mode 100644 index 0000000..cd93571 --- /dev/null +++ b/img/icons/menu.svg @@ -0,0 +1,42 @@ + + + + + + diff --git a/index.html b/index.html index c3a68e6..765bf14 100644 --- a/index.html +++ b/index.html @@ -27,17 +27,34 @@ - +
+ +
+
@@ -297,5 +314,6 @@
+ diff --git a/script.js b/script.js index e69de29..9432601 100644 --- a/script.js +++ b/script.js @@ -0,0 +1,9 @@ +"use strict"; + +// Mobile navigation +const btnNavEl = document.querySelector(".btn-mobile-nav"); +const headerEl = document.querySelector(".header"); + +btnNavEl.addEventListener("click", function () { + headerEl.classList.toggle("nav-open"); +});