Next, we’ll style the menu using CSS. We’ll start by styling the basic menu and then hide the dropdown menu by default.
/* styles.css */
body {
font-family: Arial, sans-serif;
}
.navbar {
background-color: #333;
overflow: hidden;
}
.menu {
list-style-type: none;
margin: 0;
padding: 0;
display: flex;
}
.menu-item {
position: relative;
}
.menu-item a {
display: block;
color: white;
padding: 14px 20px;
text-decoration: none;
}
.menu-item a:hover {
background-color: #575757;
}
.dropdown-menu {
display: none;
position: absolute;
background-color: #333;
min-width: 160px;
z-index: 1;
}
.dropdown-menu a {
color: white;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-menu a:hover {
background-color: #575757;
}