A piece of code written in CSS3 that controls how the cursor appears when hovering over elements in a website's navigation menu.
CSS3 offers various properties to customize cursor styles, allowing you to create unique visual feedback for users interacting with your menu.


HTML Code
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<div class="nav">
<ul>
<li class="list active">
<a href="#">
<i class="fa fa-home"></i>
<span class="text">Home</span>
</a>
</li>
<li class="list">
<a href="#">
<i class="fa fa-user"></i>
<span class="text">About</span>
</a>
</li>
<li class="list">
<a href="#">
<i class="fa fa-photo"></i>
<span class="text">Gallery</span>
</a>
</li>
<li class="list">
<a href="#">
<i class="fa fa-envelope"></i>
<span class="text">Contact</span>
</a>
</li>
<li class="list">
<a href="#">
<i class="fa fa-gear"></i>
<span class="text">Setting</span>
</a>
</li>
<div class="pointer"></div>
</ul>
</div>
CSS Code
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
:root {
--main-color:white;
}
.nav {
position: relative;
margin-top: 50px;
margin-left: 50px;
width: 400px;
height: 70px;
background-color: #028DF7;
display: flex;
justify-content: center;
align-items: center;
border-radius: 10px;
}
.nav ul {
display: flex;
width: 350px;
}
.nav ul li {
position: relative;
list-style: none;
width: 70px;
height: 70px;
z-index: 1;
}
.nav ul li a {
position: relative;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
width: 100%;
text-align: center;
font-weight: 500;
text-decoration: none;
color: var(--main-color);
}
.nav ul li a .fa {
position: relative;
display: block;
line-height: 75px;
font-size: 1.5em;
text-align: center;
transition: 0.5s;
}
.nav ul li.active a .fa {
transform: translateY(-35px);
}
.nav ul li a .text {
position: absolute;
opacity: 0;
transition: 0.5s;
transform: translateY(20px);
}
.nav ul li.active a .text {
opacity: 1;
transform: translateY(10px);
}
.pointer {
position: absolute;
top: -50%;
width: 70px;
height: 70px;
background-color:#02DBF7;
border-radius: 50%;
border: 6px solid var(--main-color);
transition: 0.5s;
}
.pointer::before {
content: '';
position: absolute;
top: 50%;
left: -21px;
width: 20px;
height: 20px;
background-color: transparent;
border-top-right-radius: 20px;
box-shadow: 0px -10px 0 0 var(--main-color);
}
.pointer::after {
content: '';
position: absolute;
top: 50%;
right: -21px;
width: 20px;
height: 20px;
background-color: transparent;
border-top-left-radius: 20px;
box-shadow: 0px -10px 0 0 var(--main-color);
}
.nav ul li:nth-child(1).active ~ .pointer {
transform: translateX(calc(70px * 0));
}
.nav ul li:nth-child(2).active ~ .pointer {
transform: translateX(calc(70px * 1));
}
.nav ul li:nth-child(3).active ~ .pointer {
transform: translateX(calc(70px * 2));
}
.nav ul li:nth-child(4).active ~ .pointer {
transform: translateX(calc(70px * 3));
}
.nav ul li:nth-child(5).active ~ .pointer {
transform: translateX(calc(70px * 4));
}
JS Code
const list = document.querySelectorAll('.list');
function activateLink(){
list.forEach( (item) => item.classList.remove('active') );
this.classList.add('active');
}
list.forEach( (item) => item.addEventListener('click', activateLink) );