I'm still beginner to programming and I want to create a beautiful transition effect when I open the dropdowm of the menu.
In the way it is done now, the menu appears instantly, without any kind of transition. In menus that do not have a dropdown, I managed to create a transition effect. But I don't know how to create this transition effect for the dropdown.
Can you tell me how do I create a transition effect for when I open the dropdown menu?
I put my code into codesandbox.io
import "./styles.scss";
import { NavLink } from "react-router-dom";
export default function App() {
const onCompany = (e) => {
e.preventDefault();
};
return (
<div className="App">
<div className="menu-content">
<ul className="menu-links">
<li>
<NavLink to="/services">Services</NavLink>
</li>
<li>
<NavLink to="/cases">Cases</NavLink>
</li>
<li className="dropdown">
<a href="/#" onClick={onCompany}>
Our company
</a>
<div className="dropdown-content">
<NavLink to="/about">About</NavLink>
<NavLink to="/careers">Carrers</NavLink>
<NavLink to="/articles">Articles</NavLink>
</div>
</li>
</ul>
</div>
</div>
);
}
.menu-content {
display: flex;
height: 104px;
justify-content: center;
}
.menu-links {
display: flex;
justify-content: space-between;
list-style-type: none;
text-decoration: none;
margin: 0;
height: 100%;
width: 45%;
}
li {
display: flex;
flex-direction: column;
justify-content: center;
font-family: Alliance2;
transition: transform 250ms ease-in-out;
&:nth-child(-n + 2) {
&:after {
display: block;
content: "";
border-bottom: solid 3px #000;
transform: scaleX(0);
transition: transform 250ms ease-in-out;
}
&:hover:after {
transform: scaleX(1);
}
}
a {
align-items: center;
color: #000;
display: flex;
font-size: 22px;
font-weight: 600;
padding: 5px;
height: 100%;
text-decoration: none;
}
&.dropdown {
.dropdown-content {
top: 100%;
}
}
}
.dropdown-content {
display: none;
min-width: 160px;
position: absolute;
text-transform: uppercase;
background-color: grey;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
top: 104px !important;
a {
display: block;
font-size: 14px;
font-weight: 600;
color: #000;
padding: 12px 16px;
text-align: center;
&:hover {
color: #fff;
}
}
}
.dropdown:hover .dropdown-content {
display: block;
}
Thank you in advance for any help.