Navbar responsive design; Now using grid instead of flexbox

This commit is contained in:
Andrew Lee 2024-01-20 00:31:03 -05:00
parent 57965c763f
commit 84df8d3ccb
Signed by: andrew
SSH key fingerprint: SHA256:bbGg1DYG5CuKl2jo1DqzvUsaTeyvhM3tjCsej5lYMg4
5 changed files with 132 additions and 22 deletions

View file

@ -2,6 +2,9 @@
import "../styles/Navbar.css" import "../styles/Navbar.css"
--- ---
<nav> <nav>
<button class="nav-toggle" aria-label="toggle navigation">
<span class='hamburger'></span>
</button>
<ul class="nav-list"> <ul class="nav-list">
<li><a href="/" class="nav-link">Home</a></li> <li><a href="/" class="nav-link">Home</a></li>
<li><a href="#" class="nav-link">Projects</a></li> <li><a href="#" class="nav-link">Projects</a></li>
@ -11,3 +14,10 @@ import "../styles/Navbar.css"
<li><a href="#" class="nav-link">Contacts</a></li> <li><a href="#" class="nav-link">Contacts</a></li>
</ul> </ul>
</nav> </nav>
<script>
document.querySelector('.nav-toggle').addEventListener('click', function() {
this.classList.toggle('active');
document.querySelector('.nav-list').classList.toggle('show');
});
</script>

View file

@ -42,7 +42,14 @@ import Navbar from '../components/Navbar.astro';
footer { footer {
text-align: center; text-align: center;
font-size: 2.4vh; font-size: 2.4vh;
padding: 1.3vh; }
h1, h2, h3, h4, h5, h6 {
font-weight: 500;
}
h2 {
font-size: 2.5vh;
} }
a { a {

View file

@ -12,16 +12,16 @@ import '../styles/index.css';
<Image src={Profile} class="avatar" alt="Andrew Lee" height={200} width={200} /> <Image src={Profile} class="avatar" alt="Andrew Lee" height={200} width={200} />
<h1 id="title">Hey, I'm Andrew Lee!</h1> <h1 id="title">Hey, I'm Andrew Lee!</h1>
<div class="social"> <div class="social">
<a href="https://linkedin.alee14.me"> <a href="https://linkedin.alee14.me" target="_blank">
<Icon name="fa6-brands:linkedin" /> <Icon name="fa6-brands:linkedin" />
</a> </a>
<a href="https://github.alee14.me"> <a href="https://github.alee14.me" target="_blank">
<Icon name="fa6-brands:github" /> <Icon name="fa6-brands:github" />
</a> </a>
<a href="https://youtube.alee14.me"> <a href="https://youtube.alee14.me" target="_blank">
<Icon name="fa6-brands:youtube" /> <Icon name="fa6-brands:youtube" />
</a> </a>
<a href="https://instagram.alee14.me"> <a href="https://instagram.alee14.me" target="_blank">
<Icon name="fa6-brands:instagram" /> <Icon name="fa6-brands:instagram" />
</a> </a>
</div> </div>
@ -58,21 +58,22 @@ import '../styles/index.css';
</ul> </ul>
<h2>Vultr (Web Server)</h2> <h2>Vultr (Web Server)</h2>
<ul> <ul>
<li>OS: Ubuntu Server</li> <li>OS: Ubuntu Server 22.04 LTS</li>
<li>CPU: Intel Xeon Processor (Skylake, IBRS)</li> <li>CPU: Intel Xeon Processor (Skylake, IBRS)</li>
<li>RAM: 1 GB</li> <li>RAM: 1 GB</li>
<li>Storage: 25 GB (and 50 GB for Block Storage)</li> <li>Storage: 25 GB (and 100 GB for Block Storage)</li>
</ul> </ul>
<h2>Proxmox</h2> <h2>Proxmox</h2>
<ul> <ul>
<li>Model: Lenovo ThinkCentre M800</li> <li>Model: Lenovo ThinkCentre M800</li>
<li>CPU: Intel Core i5-6500</li> <li>CPU: Intel Core i5 6500</li>
<li>RAM: 16 GB RAM</li> <li>RAM: 16 GB RAM</li>
<li>Storage: 500 GB SSD, 2 TB SSD</li> <li>Storage: 500 GB SSD, 2 TB SSD</li>
</ul> </ul>
</div> </div>
<div class="box"> <div class="box latest-posts">
<h1>Latest Posts</h1> <h1>Latest Posts</h1>
<p>Hello world</p>
</div> </div>
</div> </div>
</main> </main>

View file

@ -25,3 +25,75 @@ a.nav-link:hover {
a.nav-link:active { a.nav-link:active {
color: #609460; color: #609460;
} }
@media (max-width: 768px) {
ul.nav-list {
flex-direction: column;
align-items: center;
gap: 2vh;
}
}
.nav-toggle {
background: transparent;
border: none;
cursor: pointer;
display: none;
}
.nav-toggle .hamburger {
width: 30px;
height: 2px;
background: white;
display: block;
position: relative;
}
.nav-toggle .hamburger::before, .nav-toggle .hamburger::after {
content: '';
background: white;
display: block;
position: absolute;
width: 100%;
height: 100%;
}
.nav-toggle .hamburger::before {
top: -10px;
}
.nav-toggle .hamburger::after {
bottom: -10px;
}
@media (max-width: 768px) {
.nav-toggle {
display: block;
padding: 20px;
}
ul.nav-list {
flex-direction: column;
align-items: center;
gap: 2vh;
display: none;
}
ul.nav-list.show {
display: flex;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
.nav-list.show a.nav-link {
animation: fadeIn 0.5s ease-in-out forwards;
}
}

View file

@ -8,19 +8,10 @@
border-radius: 20%; border-radius: 20%;
} }
h1 {
font-weight: 500;
}
#title { #title {
font-size: 4vh; font-size: 4vh;
} }
h2 {
font-weight: 500;
font-size: 2.5vh;
}
ul { ul {
padding-left: 20px; padding-left: 20px;
font-size: 1.1em; font-size: 1.1em;
@ -48,11 +39,11 @@ p {
} }
.information { .information {
display: flex; display: grid;
flex-direction: column; grid-template-columns: 1fr 0.7fr;
flex-wrap: wrap; grid-template-rows: auto auto;
gap: 2vh; gap: 2vh;
padding: 30px 30px 30px 30px padding: 30px;
} }
.box { .box {
@ -61,3 +52,32 @@ p {
background: #3B513B; background: #3B513B;
border-radius: 20px; border-radius: 20px;
} }
.box:nth-child(1), .box:nth-child(2) {
grid-column: 1;
}
.latest-posts {
grid-column: 2;
grid-row: 1 / span 2;
}
/* Mobile view */
@media (max-width: 768px) {
.social {
font-size: 5vh;
gap: 3vh;
}
.information {
grid: auto auto auto / 1fr;
}
.box:nth-child(1), .box:nth-child(2), .latest-posts {
grid-column: 1;
}
.latest-posts {
grid-row: auto;
}
}