Mobile navigation

This commit is contained in:
blake committed 2025-10-01 16:52:57 -05:00
1 parent 35caa410ff
commit 35bed40129
6 files changed
+188 -2

No files matched your search

+53
View File
@@ -57,6 +57,50 @@
.contact-grid { .contact-grid {
gap: 0; 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) { @media (max-width: 47em) {
@@ -102,6 +146,9 @@
.contact-img { .contact-img {
grid-row: 1; grid-row: 1;
} }
.nav-links {
width: 40%;
}
} }
@media (max-width: 38em) { @media (max-width: 38em) {
@@ -111,6 +158,9 @@
.hero { .hero {
max-width: 90%; max-width: 90%;
} }
.nav-links {
width: 50%;
}
} }
@media (max-width: 31em) { @media (max-width: 31em) {
@@ -136,4 +186,7 @@
.heading-sub { .heading-sub {
max-width: 80%; max-width: 80%;
} }
.nav-links {
width: 60%;
}
} }
+24 -2
View File
@@ -50,6 +50,7 @@ html {
/* font-size: 10px; */ /* font-size: 10px; */
font-size: 62.5%; font-size: 62.5%;
scroll-behavior: smooth; scroll-behavior: smooth;
overflow-x: hidden;
} }
body { body {
@@ -59,6 +60,11 @@ body {
color: #fff; color: #fff;
background-color: #0b1532; background-color: #0b1532;
font-size: 2rem; font-size: 2rem;
overflow-x: hidden;
}
.header {
position: relative;
} }
.nav { .nav {
@@ -103,10 +109,26 @@ body {
align-items: center; align-items: center;
} }
.rocket-icon { .btn-mobile-nav {
max-width: 4rem; 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, .main-nav-link.nav-btn:link,
.nav-btn:visited { .nav-btn:visited {
transition: all 0.3s; transition: all 0.3s;
+42
View File
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
class="ionicon"
viewBox="0 0 512 512"
version="1.1"
id="svg1"
sodipodi:docname="close.svg"
inkscape:version="1.4.2 (ebf0e940d0, 2025-05-08)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs1" />
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="1.8945312"
inkscape:cx="255.73608"
inkscape:cy="256"
inkscape:window-width="2226"
inkscape:window-height="1179"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg1" />
<path
fill="none"
stroke="currentColor"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="32"
d="M368 368L144 144M368 144L144 368"
id="path1"
style="fill:#000000;fill-opacity:1;stroke:#ffffff;stroke-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

+42
View File
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
class="ionicon"
viewBox="0 0 512 512"
version="1.1"
id="svg1"
sodipodi:docname="menu-outline.svg"
inkscape:version="1.4.2 (ebf0e940d0, 2025-05-08)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs1" />
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="1.8945312"
inkscape:cx="255.73608"
inkscape:cy="256"
inkscape:window-width="2226"
inkscape:window-height="1179"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg1" />
<path
fill="none"
stroke="currentColor"
stroke-linecap="round"
stroke-miterlimit="10"
stroke-width="32"
d="M80 160h352M80 256h352M80 352h352"
id="path1"
style="stroke:#ffffff;stroke-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

+18
View File
@@ -27,6 +27,7 @@
</title> </title>
</head> </head>
<body> <body>
<header class="header">
<nav class="nav"> <nav class="nav">
<a href="#home" <a href="#home"
><img class="logo" src="img/logo.svg" alt="Cosmically Creative Logo" ><img class="logo" src="img/logo.svg" alt="Cosmically Creative Logo"
@@ -37,7 +38,23 @@
<li><a class="main-nav-link" href="#contact">Contact</a></li> <li><a class="main-nav-link" href="#contact">Contact</a></li>
<li><a class="main-nav-link" href="#services">Services</a></li> <li><a class="main-nav-link" href="#services">Services</a></li>
</ul> </ul>
<button class="btn-mobile-nav">
<img
class="icon-mobile-nav"
src="img/icons/menu.svg"
alt="menu icon"
name="open"
/>
<img
class="icon-mobile-nav"
src="img/icons/close.svg"
alt="menu icon"
name="close"
/>
</button>
</nav> </nav>
</header>
<main> <main>
<section class="hero-section" id="home"> <section class="hero-section" id="home">
<div class="hero"> <div class="hero">
@@ -297,5 +314,6 @@
</footer> </footer>
</section> </section>
</main> </main>
<script src="script.js"></script>
</body> </body>
</html> </html>
+9
View File
@@ -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");
});