Skip to content

Instantly share code, notes, and snippets.

@Stwissel
Last active August 22, 2025 04:59
Show Gist options
  • Select an option

  • Save Stwissel/858114abf9827533c5b4e4ca655005d0 to your computer and use it in GitHub Desktop.

Select an option

Save Stwissel/858114abf9827533c5b4e4ca655005d0 to your computer and use it in GitHub Desktop.
Mix of Grid and flexbox
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Grid + Flex Layout</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
display: grid;
grid-template-rows: auto 1fr auto;
grid-template-areas:
"header"
"content"
"footer";
height: 100vh;
margin: 0;
font-family: sans-serif;
}
header {
grid-area: header;
display: flex;
justify-content: space-between;
align-items: center;
position: fixed;
top: 0;
left: 0;
right: 0;
height: 60px;
background: #333;
color: white;
padding: 0 1rem;
z-index: 1000;
}
header nav {
display: flex;
gap: 1rem;
}
header button.menu-toggle {
display: none;
background: none;
border: none;
color: white;
font-size: 1.5rem;
}
main {
grid-area: content;
display: grid;
grid-template-columns: 3fr 250px;
gap: 1rem;
margin-top: 60px; /* offset header */
margin-bottom: 40px; /* offset footer */
padding: 1rem;
}
article {
background: #eee;
padding: 1rem;
border-radius: 4px;
}
aside {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
aside div {
background: #fdd;
padding: 0.5rem;
flex: 1 1 200px; /* responsive width */
text-align: center;
border-radius: 4px;
xborder: 3px solid red;
}
footer {
grid-area: footer;
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 40px;
background: #222;
color: white;
display: flex;
justify-content: center;
align-items: center;
}
/* Responsive tweaks */
@media (max-width: 868px) {
main {
grid-template-columns: 1fr; /* aside below main */
}
header nav {
display: none; /* hide menu items */
}
header button.menu-toggle {
display: block; /* show toggle */
}
}
</style>
</head>
<body>
<header>
<div><h1>Logo</h1>a nice one</div>
<nav>
<a href="#">Home</a>
<a href="#">About</a>
<a href="#">Contact</a>
</nav>
<button class="menu-toggle"></button>
</header>
<main>
<div>
<h1>Main Content</h1>
<article>
<h2>Soul man</h2>
<p>A wonderful serenity has taken possession of my entire soul,
like these sweet mornings of spring which I enjoy with my whole heart.
I am alone, and feel the charm of existence in this spot,
which was created for the bliss of souls like mine.
I am so happy, my dear friend, so absorbed in the exquisite sense of mere tranquil existence,
that I neglect my talents. I should be incapable of drawing a single stroke at the present moment;
and yet I feel that I never was a greater artist than now.
When, while the lovely valley teems with vapour around me, and the meridian sun strikes
the upper surface of the impenetrable foliage of my trees, and but a few stray gleams steal
into the inner sanctuary, I throw myself down among the tall grass by the trickling stream;
and, as I lie close to the earth, a thousand unknown plants are noticed by me:
when I hear the buzz of the little world among the stalks, and grow familiar with the countless
indescribable forms of the insects and flies, then I feel the presence of the Almighty,
who formed us in his own image, and the breath
</p>
</article>
</div>
<aside>
<div>Block 1</div>
<div>Block 2</div>
<div>Block 3</div>
<div>Block 4</div>
<div>Block 5</div>
</aside>
</main>
<footer>
&copyl; 2025 some footer
</footer>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment