Tutorial Description :
In this Tutorial I will create a Active Tab Animation Menu Bar using CSS only .
I will use font Font Awesome for the icons and google fonts with the font style of Roboto for the main font.
For the navigation I will use display flex so CSS3 flexbox.
I will also use pseudo element and pseudo classes as hover, after, before, and active in order to hide and make content visible .

Img:
Font Awesome
Google Fonts
HTML :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="https://fonts.googleapis.com/css?family=Dancing+Script|Open+Sans&display=swap" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<title>Active Tab Animation</title>
</head>
<body>
<header>
<h1>Active Tab Animation</h1>
</header>
<nav class="nav">
<ul class="nav_items">
<li><a href="#">home</a></li>
<li><a href="#">home</a></li>
<li><a href="#">home</a></li>
<li><a href="#">home</a></li>
<li><a href="#">home</a></li>
<div class="slide slide-start"></div>
</ul>
</nav>
</body>
</html>
CSS:
* {
margin: 0;
padding: 0;
list-style: none;
text-decoration: none;
font-size: 16px;
}
body {
background-image: url(/img/road-landscape-nature-forest-39811.jpg);
background-position: center/center;
background-repeat: no-repeat;
background-size: cover;
font-family: "Open Sans";
}
@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
header h1 {
text-align: center;
font-family: "Dancing Script";
font-size: 12rem;
color: #fff;
position: relative;
top: 20vh;
text-shadow: 1px 1px 5px #111;
animation: fade-in 5s ease-in;
}
.nav {
position: relative;
margin: 25% auto;
height: 80px;
width: 600px;
background-color: red;
border: 1px solid #333;
box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.5);
border-radius: 5px;
background-color: transparent;
animation: fade-in 1.5s ease-in;
}
.nav_items {
display: flex;
justify-content: space-around;
justify-items: center;
align-items: center;
height: 100%;
position: relative;
}
.nav_items li {
position: relative;
height: 100%;
width: 100%;
margin: auto;
padding-top: 1.5rem;
text-align: center;
display: block;
cursor: pointer;
}
.nav_items li a {
color: #fff;
font-size: 1.3rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 1px;
text-shadow: 2px 2px 5px #111;
z-index: 1;
height: 100%;
width: 100%;
position: relative;
}
.nav_items .slide {
position: absolute;
height: 100%;
top: 0;
left: 0;
background-color: rgba(230, 170, 75, 0.8);
z-index: 0;
transition: all 0.4s ease;
}
.nav_items .slide-start,
li:nth-child(1):hover ~ .slide {
width: 120px;
left: 0;
border-radius: 5px 0 0 5px;
}
li:nth-child(2):hover ~ .slide {
width: 120px;
left: 120px;
border-radius: 0;
}
li:nth-child(3):hover ~ .slide {
width: 120px;
left: 240px;
border-radius: 0;
}
li:nth-child(4):hover ~ .slide {
width: 120px;
left: 360px;
border-radius: 0;
}
li:nth-child(5):hover ~ .slide {
width: 120px;
left: 480px;
border-radius: 0 5px 5px 0;
}
My Course: Web Development HTML CSS & JS Beginner to Advance
