Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Sh00k-ThaD3v/ca36c9d57871e052f2d7681f9e860bf0 to your computer and use it in GitHub Desktop.
Save Sh00k-ThaD3v/ca36c9d57871e052f2d7681f9e860bf0 to your computer and use it in GitHub Desktop.
Codepen Challenge: Huge Headers/Mega Menus

Codepen Challenge: Huge Headers/Mega Menus

Missed last week's challenge Mega Menus. Combined it with this week's challenge Huge Headers to make a responsive full screen landing/hero page with a overlay menu for a travel website.

A Pen by GEAUX⚜️TECH on CodePen.

License.

<div class="page-wrap">
<header class="page-header">
<nav>
<h1>CPC | Travel</h1>
<ul>
<li>About Us</li>
<li>Contact Us</li>
<li id="burger">
<span></span>
<span></span>
<span></span>
</li>
</ul>
</nav>
<main>
<article id="hero-1" style="--i: 5">
<div class="hero-info">
<h2>Travel the</h2>
<h1>World</h1>
<h3>Pragser Wildsee, Italy</h3>
</div>
<div class="hero-image hi-1"></div>
</article>
<article id="hero-2" style="--i: 4">
<div class="hero-info">
<h2>Savour the</h2>
<h1>Journey</h1>
<h3>Marignier, France</h3>
</div>
<div class="hero-image hi-2"></div>
</article>
<article id="hero-3" style="--i: 3">
<div class="hero-info">
<h2>Expand Your</h2>
<h1>Horizons</h1>
<h3>Hooker Valley Track, New Zealand</h3>
</div>
<div class="hero-image hi-3"></div>
</article>
<article id="hero-4" style="--i: 2">
<div class="hero-info">
<h2>Explore and</h2>
<h1>Reflect</h1>
<h3>Dolmites, Italy</h3>
</div>
<div class="hero-image hi-4"></div>
</article>
<article id="hero-5" style="--i: 1">
<div class="hero-info">
<h2>Change Your</h2>
<h1>Perspective</h1>
<h3>Phuket, Thailand</h3>
</div>
<div class="hero-image hi-5"></div>
</article>
</main>
</header>
<section>
<ul class="level-1">
<li>
<h3>Destinations</h3>
<ul class="level-2">
<li>
<p>Asia</p>
<ul class="level-3">
<li>Bali</li>
<li>Cambodia</li>
<li>Georgia</li>
<li>India</li>
<li>Indonesia</li>
<li>Laos</li>
<li>Malaysia</li>
<li>Maldives</li>
<li>Myanmar</li>
<li>Philippines</li>
<li>Singapore</li>
<li>Sri Lanka</li>
<li>Thailand</li>
<li>Uzbekistan</li>
<li>Vietnam</li>
</ul>
</li>
<li>
<p>Europe</p>
<ul class="level-3">
<li>Czech Republic</li>
<li>France</li>
<li>Georgia</li>
<li>Greece</li>
<li>Hungary</li>
<li>Iceland</li>
<li>Italy</li>
<li>Malta</li>
<li>Netherlands</li>
<li>Poland</li>
<li>Portugal</li>
<li>Spain</li>
<li>Turkey</li>
</ul>
</li>
<li>
<p>Africa</p>
<ul class="level-3">
<li>Egypt</li>
<li>Maurtius</li>
<li>Morocco</li>
</ul>
</li>
<li>
<p>Middle East</p>
<ul class="level-3">
<li>Egypt</li>
<li>Jordan</li>
<li>Oman</li>
<li>Turkey</li>
</ul>
</li>
</ul>
</li>
<li>
<h3>Travel Tips</h3>
<ul>
<li>Going on a trip</li>
<li>Travel Insurance</li>
<li>Working abroad</li>
<li>Saving</li>
<li>Instagram tips</li>
</ul>
<p><small>More tips...</small></p>
</li>
<li>
<h3>Resources</h3>
<ul>
<li>Personalised travel advice</li>
<li>Where we book our travels</li>
<li>Become a booking agent</li>
</ul>
<p><small>More resources...</small></p>
</li>
<li>
<h3>About Us</h3>
<ul>
<li>Our story</li>
<li>Work with us</li>
<li>Instagram</li>
<li>YouTube</li>
</ul>
</li>
</ul>
</section>
</div>
let burger = document.getElementById("burger");
let overlay = document.querySelector("section");
let heroImage = document.querySelector(".hero-image");
let showMenu = false;
let del = 3;
let i = 1;
let tl = gsap.timeline({
repeat: -1,
yoyo: true,
ease: "expo.out"
});
overlay.style.display = "none";
burger.addEventListener("click", (e) => {
showMenu = !showMenu;
if (showMenu) {
burger.classList.add("active");
overlay.style.display = "block";
gsap.to(overlay, 1, {
clipPath: "polygon(0% 0%, 100% 0, 100% 100%, 0% 100%)",
ease: "expo.in"
});
} else {
burger.classList.remove("active");
gsap.to(overlay, 1, {
clipPath: "polygon(0% 0%, 100% 0%, 100% 0%, 0% 0%)",
ease: "expo.out",
onComplete: () => (overlay.style.display = "none")
});
}
});
gsap.set(["#hero-1 h2, #hero-1 h1, #hero-1 h3"], {
clipPath: "polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)"
});
gsap.set(
[
`#hero-2 h2, #hero-3 h2, #hero-4 h2, #hero-5 h2,
#hero-2 h1, #hero-3 h1, #hero-4 h1, #hero-5 h1,
#hero-2 h3, #hero-3 h3, #hero-4 h3, #hero-5 h3`
],
{
clipPath: "polygon(0% 0%, 0% 0%, 0% 100%, 0% 100%)"
}
);
while (i < 5) {
tl.to(`#hero-${i} h2`, 0.9, {
clipPath: "polygon(0% 0%, 0% 0%, 0% 100%, 0% 100%)",
delay: del
})
.to(
`#hero-${i} h1`,
0.9,
{
clipPath: "polygon(0% 0%, 0% 0%, 0% 100%, 0% 100%)"
},
"-=0.3"
)
.to(
`#hero-${i} h3`,
0.9,
{
clipPath: "polygon(0% 0%, 0% 0%, 0% 100%, 0% 100%)"
},
"-=0.3"
)
.to(
`#hero-${i} .hi-${i}`,
0.7,
{
clipPath: "polygon(0% 0%, 0% 0%, 0% 100%, 0% 100%)"
},
"-=1"
)
.to(`#hero-${i + 1} h2`, 0.9, {
clipPath: "polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)"
})
.to(
`#hero-${i + 1} h1`,
0.9,
{
clipPath: "polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)"
},
"-=0.3"
)
.to(
`#hero-${i + 1} h3`,
0.9,
{
clipPath: "polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)"
},
"-=0.3"
);
i++;
}
<script src="https://unpkg.co/gsap@3/dist/gsap.min.js"></script>
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;800&display=swap");
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
font-family: "Poppins", sans-serif;
--black: #242424;
--white: #f5f5f5;
--pill: #e0d4be;
--red: #cc033f;
}
ul {
list-style: none;
}
.page-wrap {
position: relative;
}
header {
width: 100%;
min-height: 100vh;
overflow-x: hidden;
}
/* NAV: Top Menu Section
----------------------------------------------- */
nav {
width: 100%;
position: fixed;
z-index: 10;
padding: 1em 5em;
display: flex;
justify-content: space-between;
}
nav h1 {
font-size: clamp(1.2rem, 6vw, 3rem);
font-weight: normal;
text-transform: uppercase;
color: var(--pill);
font-size: 1.3rem;
background-color: var(--red);
padding: 5px 10px;
}
nav ul {
display: flex;
color: var(--white);
}
nav ul li:not(#burger) {
visibility: hidden;
margin-right: 1.5em;
}
#burger {
width: min-content;
height: 28px;
display: flex;
flex-direction: column;
justify-content: space-evenly;
cursor: pointer;
}
#burger span {
display: block;
height: 3px;
width: 22px;
background-color: var(--red);
border-radius: 200px;
transition: transform 0.3s 0.3s;
}
.active span:nth-of-type(1) {
transform: translateY(-3px) scaleX(1.3);
}
.active span:nth-of-type(3) {
transform: translateY(3px) scaleX(1.3);
}
/* MAIN: Slider Section
----------------------------------------------- */
main {
width: 100vw;
height: 100vh;
position: relative;
overflow: hidden;
}
article {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
z-index: var(--i);
}
.hero-info {
position: absolute;
top: 50%;
left: 5%;
transform: translateY(-50%);
z-index: 8;
}
.hero-info h2 {
font-size: clamp(2rem, 9vw, 5rem);
line-height: clamp(2rem, 9vw, 5rem);
text-transform: uppercase;
}
.hero-info h1 {
color: var(--white);
font-size: clamp(3.2rem, 10vw, 7rem);
line-height: clamp(3.2rem, 10vw, 7rem);
text-transform: uppercase;
text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.5);
}
.hero-info h3 {
color: var(--white);
font-size: 1.6rem;
font-weight: normal;
margin-top: 2em;
}
@supports (-webkit-text-stroke: 3px var(--pill)) {
.hero-info h2 {
color: transparent;
-webkit-text-stroke: 3px var(--pill);
text-shadow: none;
}
}
.hero-image {
width: 100%;
height: 100%;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
}
.hi-1 {
background-image: url("https://images.unsplash.com/photo-1501785888041-af3ef285b470?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2070&q=80");
}
/* Photo by Lucas Favre
https://unsplash.com/photos/BRTV55ErUZg
----------------------------------------------- */
.hi-2 {
background-image: url("https://images.unsplash.com/photo-1517057011470-8f36d636e6ca?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2070&q=80");
}
/* Photo by Roell de Ram
https://unsplash.com/photos/2DM7eOR5iyc
----------------------------------------------- */
.hi-3 {
background-image: url("https://images.unsplash.com/flagged/photo-1552035791-b3cc1632e933?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2069&q=80");
}
/* Photo by Go to Bernd Wahlbrinck
https://unsplash.com/photos/lVVvYiR66kw
----------------------------------------------- */
.hi-4 {
background-image: url("https://images.unsplash.com/photo-1574700273608-7962d3602a9f?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2070&q=80");
}
/* Photo by Micheal Schofield
https://unsplash.com/photos/d0ohwP3BRf4
----------------------------------------------- */
.hi-5 {
background-image: url("https://images.unsplash.com/photo-1605045544284-d13c6d6a60a6?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2070&q=80");
}
/* SECTION: Overlay Menu Section
----------------------------------------------- */
section {
position: absolute;
top: 0;
left: 0;
z-index: 9;
min-height: 100vh;
padding: 8em 5em 2em 5em;
background-color: var(--white);
background-image: url("https://www.transparenttextures.com/patterns/church.png");
clip-path: polygon(0% 0%, 100% 0%, 100% 0%, 0% 0%);
}
.level-1 {
display: grid;
grid-template-columns: 65% 1fr;
grid-auto-rows: min-content;
grid-gap: 2em;
}
.level-1 h3 {
font-weight: 600;
font-size: 1.8rem;
text-transform: uppercase;
}
.level-1 p {
margin: 0.5em 0 0 0.5em;
}
.level-1 p small {
font-size: 1rem;
opacity: 0.5;
cursor: pointer;
}
.level-1 p small:hover {
opacity: 1;
color: var(--red);
}
.level-1 ul > li {
font-size: 1.2rem;
padding: 0.3em;
transition: color 0.3s;
}
.level-1 ul > li:hover {
color: var(--red);
cursor: pointer;
}
.level-1 li:nth-of-type(1) {
grid-column: 1/2;
grid-row: 1/4;
}
.level-1 li:nth-of-type(2) {
grid-column: 2/3;
grid-row: 1/2;
}
.level-1 li:nth-of-type(3) {
grid-column: 2/3;
grid-row: 2/3;
}
.level-1 li:nth-of-type(4) {
grid-column: 2/3;
grid-row: 3/4;
}
.level-2 {
padding: 0.3em 1em;
}
.level-2 li p {
color: var(--red);
font-size: 1.3rem;
font-weight: 600;
margin: 1em 0;
text-transform: uppercase;
border-bottom: 1px solid #fde0ac;
}
.level-3 {
display: flex;
flex-wrap: wrap;
}
.level-3 li {
padding: 0.5em 1em !important;
background-color: var(--pill);
border-radius: 500px;
margin-right: 10px;
margin-bottom: 10px;
font-size: 1rem !important;
cursor: pointer;
color: var(--black);
}
@media screen and (max-width: 600px) {
nav {
padding: 1em 2em;
}
nav h1 {
font-size: 0.9rem;
}
section {
padding: 8em 2em 2em 2em;
}
.level-1 {
grid-template-columns: 1fr;
}
.level-1 li:nth-of-type(1) {
grid-column: 1/2;
grid-row: 1/2;
}
.level-1 li:nth-of-type(2) {
grid-column: 1/2;
grid-row: 2/3;
}
.level-1 li:nth-of-type(3) {
grid-column: 1/2;
grid-row: 3/4;
}
.level-1 li:nth-of-type(4) {
grid-column: 1/2;
grid-row: 4/5;
}
}
<link href="https://fonts.googleapis.com/css2?family=Poppins&amp;display=swap" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment