JSFiddle - React, Tailwind, and code Playground
by Alexandru Gatea
HTML
<div class="nav">
<div class="nav-cart">
<button>Cart Icon</button>
<div class="drop">
</div>
</div>
</div>
SCSS
.nav {
background: white;
padding: 20px ;
display: flex;
justify-content: flex-end;
align-items: center;
button {
width: auto;
height: 40px;
border-radius: 4px;
background: black;
color: white;
box-shadow: none;
outline: none;
position: relative;
cursor: pointer;
}
.nav-cart {
position: relative;
}
.drop {
position: absolute;
right: 0;
top: calc(100% + 30px);
width: 300px;
height: 400px;
z-index: 100;
background: white;
border-radius: 4px;
background: white;
border: 1px solid #eee;
box-shadow: 1px 1px 1px 0px rgba(0,0,0,0.3);
transition: all 0.3s ease;
opacity: 0;
&.active {
top: calc(100% + 20px);
opacity: 1;
box-shadow: 3px 5px 20px 0px rgba(0,0,0,0.3);
}
}
}
JavaScript
$('.nav-cart button').on('click', function() {
$('.drop').toggleClass('active');
});