<nav class="nav">
<a href="#" class="nav__logo">CompanyLogo</a>
<!-- focus on this div -->
<div class="nav__menucontainer">
<div class="nav__listcontainer" tabindex="0">
<ul class="nav__menu" id="navmenu">
<li class="nav__item">
<a href="#" class="nav__link">About</a>
</li>
<li class="nav__item">
<a href="#" class="nav__link">Projects</a>
</li>
<li class="nav__item">
<a href="#" class="nav__link">Contact</a>
</li>
<li class="nav__item">
<a href="#" class="nav__link">Blog</a>
</li>
</ul>
<!-- we use href="#!" when the anchor tag takes us nowhere -->
<a id="hamburger" href="#!" title="menu" class="nav__hamburger">
<i class="fa fa-2x fa-hamburger"></i>
</a>
</div>
<a href="#!" title="close menu" class="nav__hamburgerclose"><i class="fa fa-2x fa-times-circle"></i></a>
</div>
</nav>
<div class="container">
<!-- svg is placed to see the glass morphism effect -->
<svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" id="blobSvg">
<defs>
<linearGradient id="gradient" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" style="stop-color: rgb(255, 95, 109);"></stop>
<stop offset="100%" style="stop-color: rgb(255, 195, 113);"></stop>
</linearGradient>
</defs>
<path id="blob" d="M365,286Q374,322,337.5,330.5Q301,339,275.5,410.5Q250,482,221.5,415Q193,348,154.5,337.5Q116,327,82,288.5Q48,
250,57,197Q66,144,98,93.5Q130,43,190,76Q250,109,304,86Q358,63,361,123.5Q364,184,360,217Q356,250,365,286Z" fill="url(#gradient)"></path>
</svg>
</div>
/* most part is for styling and you can safely ignore it */
/* comments are placed wherever necessary */
*,
*::before,
*::after {
box-sizing: border-box;
}
body {
background-color: #f5f5f5;
margin: 0;
font-family: sans-serif;
}
a {
text-decoration: none;
}
/* --- You know what this is --- */
#blobSvg {
max-width: 520px;
}
.nav {
display: flex;
justify-content: space-between;
align-items: center;
position: fixed;
width: 100%;
background-color: rgba(51, 51, 51, 0.85);
color: #efefef;
z-index: 5;
padding: 1rem;
}
.nav__logo {
text-decoration: none;
color: inherit;
font-weight: 700;
font-size: 1.5rem;
}
.nav__menucontainer {
position: relative;
}
.nav__hamburger {
color: inherit;
min-width: 32px;
min-height: 32px;
transition: opacity 80ms linear;
/* hiding the hamburger icon on large screen sizes */
display: none;
opacity: 0;
}
.nav__hamburgerclose {
color: inherit;
position: absolute;
top: 0;
min-width: 32px;
min-height: 32px;
transition: opacity 150ms linear;
/* hiding the close icon and... */
display: none;
opacity: 0;
z-index: -1; /* pushing it behind the hamburger icon so that hamburger icon can be clicked */
}
.nav__menu {
padding: 0;
margin: 0;
list-style: none;
display: flex;
flex-wrap: wrap;
font-size: 0.95rem;
font-weight: 500;
}
.nav__item {
margin-right: 1rem;
}
.nav__link {
color: inherit;
text-decoration: none;
width: 100%;
}
.nav__link:hover,
.nav__link:focus-visible {
box-shadow: 0 4px 0 -1px #a2e718;
}
/* ----- smaller screen sizes ----- */
@media (max-width: 520px) {
.nav__hamburger {
/* making the hamburger icon visible on smaller screen sizes */
display: flex;
opacity: 1;
}
.nav__menu {
/* move menu offscreen */
opacity: 0;
position: fixed;
visibility: none;
top: -1000px;
/* just some styles */
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: #25310c;
box-shadow: 0 0 30px rgba(0, 0, 0, 0.19);
border: 2px solid rgba(255, 255, 255, 0.2); /* part of glass morphism effect */
border-radius: 2rem 0 2rem 2rem;
background: rgba(255, 255, 255, 1);
}
/* uncomment the line below to activate on hover. */
/* .nav__listcontainer:hover .nav__menu, */
.nav__listcontainer:focus .nav__menu,
.nav__listcontainer:focus-within .nav__menu {
position: absolute;
visibility: visible;
opacity: 1;
top: 2rem;
right: 1.5rem;
}
/* if the browser supports backdrop-filter property,
then add it (for the glass morphism effect) */
@supports (backdrop-filter: blur(10px)) {
/* uncomment the line below to activate on hover. */
/* .nav__listcontainer:hover .nav__menu, */
.nav__listcontainer:focus .nav__menu,
.nav__listcontainer:focus-within .nav__menu {
background: rgba(255, 255, 255, 0.7);
backdrop-filter: blur(10px);
}
}
.nav__item {
margin-right: 0;
padding: 0.5rem 1.5rem;
}
.nav__link:hover,
.nav__link:focus {
opacity: 0.8;
color: #121212;
}
/* uncomment the line below to activate on hover. */
/* NOTE: Hover is not recommended, it will have side effects on this */
/* .nav__listcontainer:hover .nav__hamburger, */
.nav__listcontainer:focus .nav__hamburger,
.nav__listcontainer:focus-within .nav__hamburger {
opacity: 0;
z-index: -1;
}
/* uncomment the line below to activate on hover. */
/* NOTE: Hover is not recommended, it will have side effects on this */
/* .nav__listcontainer:hover + .nav__hamburgerclose, */
.nav__listcontainer:focus + .nav__hamburgerclose,
.nav__listcontainer:focus-within + .nav__hamburgerclose {
display: flex;
opacity: 1;
z-index: 1;
}
}
.container {
display: flex;
flex-direction: column;
align-items: center; /* centering elements inside .container */
width: 100%;
max-width: 720px;
margin: 0 auto; /* centering container within its parent */
padding: 2em 1.5em;
background: #fff;
}
// No need for now
This Pen doesn't use any external JavaScript resources.