HTML
<header id="js-header">
<div class="container">
<a href="" class="logo"> </a>
<nav>
<div class="dropdown-produtos js-dropdown-produtos">
<a href="#" target="_self" class="item-produtos">
<strong>Cartão de crédito</strong>
<p>Cartão de crédito sem anuidade</p>
</a>
<a href="#" target="_self" class="item-produtos">
<strong>Cartão pré-pago</strong>
<p>Cartão de débito internacional Neon</p>
</a>
<a href="#" target="_self" class="item-produtos">
<strong>Neon Mais</strong>
<p>4 saques grátis para quem compra com a Neon</p>
</a>
<a href="#" target="_self" class="item-produtos">
<strong>Investimentos</strong>
<p>A evolução da poupança</p>
</a>
<a href="#" target="_self" class="item-produtos">
<strong>Empréstimo pessoal</strong>
<p>Faça uma simulação de empréstimo pessoal</p>
</a>
</div>
<ul>
<li>
<a href="" class="js-btn-dropdown-produtos">Produtos Neon</a>
</li>
<li>
<a href="">Conta digital PJ</a>
</li>
<li><a href="">Quem somos</a></li>
<li><a href="">Blog</a></li>
<li><a href="">Ajuda</a></li>
</ul>
<button class="btn-tertiary">Abra sua conta digital</button>
</nav>
<button class="button-mobile" id="js-btn-menu-mobile">
<img src="./img/btn-mobile.svg" />
</button>
<div class="menu-mobile">
<div class="overlay js-overlay"></div>
<aside>
<img src="./img/logo-color.svg" class="logo" alt="" />
<ul>
<li>
<a href="" class="js-btn-dropdown-produtos">Produtos Neon</a>
</li>
<li>
<a href="">Conta digital PJ</a>
</li>
<li><a href="">Quem somos</a></li>
<li><a href="">Blog</a></li>
<li><a href="">Ajuda</a></li>
</ul>
</aside>
</div>
</div>
</header>
SCSS
header {
display: flex;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 8.8rem;
border-bottom: 2px solid rgba(255, 255, 255, 0.2);
z-index: 100;
transition: all 0.3s;
.container {
@include flex(row, center, space-between);
}
.logo {
display: inline-block;
background: url(../img/logo.svg) no-repeat center center;
width: 13.2rem;
height: 3rem;
background-size: 100%;
}
&.fixed-menu {
background-color: $cor36;
box-shadow: 0 0 3rem 0 rgba(0, 0, 0, 0.3);
.logo {
background-image: url(../img/logo-color.svg);
}
nav {
ul {
li {
a {
color: $cor32;
&:hover {
color: $cor11;
}
}
}
}
.btn-tertiary {
color: $cor11;
border: 0.1rem solid $cor11;
&:hover {
background-color: $cor11;
color: $cor36;
}
}
}
}
nav {
display: flex;
align-items: center;
position: relative;
.dropdown-produtos {
position: absolute;
top: 7rem;
left: -13rem;
width: 100%;
max-width: 37.3rem;
background: $cor36;
border-radius: 0.6rem;
padding: 4rem;
z-index: 5;
//Efeito para vir de baixo
transform: translateY(2rem);
// Forma para esconder e poder aplicar transition
opacity: 0;
pointer-events: none;
transition: all 0.3s;
box-shadow: 0.3rem 0.3rem 0.3rem 0.3rem rgba(0, 0, 0, 0.1);
&.active {
opacity: 1;
pointer-events: all;
transform: translateY(0);
}
&:after {
content: "";
position: absolute;
bottom: 0;
width: 29.3rem;
height: 0.5rem;
background: $cor20;
border-radius: 1.2rem 1.2rem 0 0;
z-index: 2;
}
a.item-produtos {
&:not(last-child) {
display: block;
margin-bottom: 2.8rem;
}
&:hover {
strong {
color: $cor10;
}
}
strong {
font-weight: 600;
font-size: 1.6rem;
line-height: 1.9rem;
color: $cor32;
display: block;
margin-bottom: 0.4rem;
transition: all 0.3s;
}
p {
font-size: 1.4rem;
line-height: 150%;
color: $cor33;
}
}
}
ul {
display: flex;
align-items: center;
margin-right: 5.9rem;
li {
&:not(:first-child) {
margin-left: 4.8rem;
}
a {
font-family: "Poppins", sans-serif;
font-weight: 500;
font-size: 1.6rem;
line-height: 125%;
text-align: right;
color: $cor36;
transition: all 0.3s;
&:hover {
color: $cor20;
transition: all 0.3s;
}
}
}
}
}
.button-mobile {
display: none;
}
@include responsive(1110px) {
nav {
.dropdown-produtos {
display: none;
}
ul {
margin-right: 3rem;
li {
&:not(:first-child) {
margin-left: 2.5rem;
}
}
}
}
}
@include responsive(991px) {
.logo {
max-width: 10.8rem;
}
nav {
display: none;
}
.button-mobile {
display: block;
}
}
@include responsive(500px) {
height: 7.3rem;
nav {
.btn-tertiary {
display: none;
}
}
}
}
.menu-mobile {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 2022;
opacity: 0;
pointer-events: none;
transition: opacity 0.3s;
.overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 0;
}
aside {
position: fixed;
top: 0;
left: 0;
width: 75%;
height: 100%;
background: $cor36;
padding: 3rem;
transform: translateX(-100%);
transition: transform 0.3s;
.logo {
max-width: 15rem;
margin-bottom: 4rem;
}
ul {
li {
a {
display: block;
padding: 1.5rem 0;
font-size: 1.8rem;
color: $cor32;
}
}
}
}
}
.menu-opened {
overflow: hidden;
.menu-mobile {
opacity: 1;
pointer-events: all;
aside {
transform: translateX(0%);
@include flex(column, center, flex-start);
padding-top: 10rem;
ul {
@include flex(column, center, center);
}
}
}
}
JS
const btnDropdownProdutos = document.querySelector(".js-btn-dropdown-produtos");
const dropdownProdutos = document.querySelector(".js-dropdown-produtos");
function openDropdownProdutos(event) {
event.preventDefault();
dropdownProdutos.classList.toggle("active");
}
btnDropdownProdutos.addEventListener("mouseenter", openDropdownProdutos);
dropdownProdutos.addEventListener("mouseleave", openDropdownProdutos);