Here is the current navbar I have
I want to achieve a scenario where clicking on any of the navbar elements triggers a specific action
Below is the HTML code for the navbar:
<div class="navbar-container">
<div class="navbar-wrapper">
<div class="text-radius home-radius">
<p><a href="#" class="nav-anchor">Home</a></p>
</div>
<div class="text-radius profile-radius">
<p><a href="#profile" class="nav-anchor">Profile</a></p>
</div>
<div class="text-radius contact-radius">
<p><a href="#contact" class="nav-anchor">Contact</a></p>
</div>
</div>
</div>
The CSS styling for the navbar is as follows:
.navbar-container {
display: flex;
justify-content: center;
}
.navbar-wrapper {
font-size: 13px;
margin: 20px 20px;
display: flex;
justify-content: center;
align-items: center;
gap: 5px;
border-radius: 5em;
background-color: var(--lightgrey);
width: 18.8em;
height: 3em;
}
.nav-anchor {
text-decoration: none;
color: var(--black);
}
.text-radius {
display: flex;
align-items: center;
justify-content: center;
width: 5.8em;
height: 2.5em;
border-radius: 5em;
}
.home-radius:active {
background-color: var(--white);
}
.profile-radius:active {
background-color: var(--white);
}
.contact-radius:active {
background-color: var(--white);
}
My attempts so far include using :active, :focus & :target pseudo-classes, but they haven't been successful. I'm currently stuck and seeking solutions without resorting to JavaScript.