I have implemented a CSS effect where hovering over text creates an underline that expands and contracts in size. However, I now want to display an icon alongside the text that appears and disappears along with the underline effect. When I try using display: block for the icon, it interferes with the hover effect on the text. How can I resolve this issue?
CSS:
/* You can add global styles to this file, and also import other style files */
.navbar {
display: flex;
flex-direction: row;
align-items: flex-start;
padding: 0px;
gap: 40px;
position: absolute;
width: 639.98px;
height: 32px;
left: 363px;
top: 72px;
background: rgba(0, 0, 0, 0.2);
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25), 0px 4px 4px rgba(0, 0, 0, 0.25);
padding-top: 72px;
}
.sobre {
width: 108.1px;
height: 32px;
flex: none;
order: 0;
flex-grow: 0;
color: white;
font-family: 'Outfit', sans-serif;
font-style: normal;
font-weight: 900;
font-size: 20.7558px;
line-height: 28px;
text-decoration: none;
position: relative;
/* Horizontal gradient */
background-image: linear-gradient(90deg, rgba(251, 62, 107, 0.95) 10%, #8F00FF 91.6%);
background-size: 40% 3px;
background-position: left bottom;
background-repeat: no-repeat;
transition: background-size 300ms ease;
}
.sobreImg {
display: block;
position: absolute;
left: 110px;
top: 2px;
visibility: hidden;
}
.sobreImg:hover {
display: block;
visibility: visible;
}
.sobre:hover {
background-size: 100% 3px;
}
HTML:
<nav class="navbar">
<a class="ferramentas" routerLink="/">tools
<img src="../assets/icons/tools.svg" class="toolsImg">
</a>
<a class="contato" routerLink="/">contact
<img src="../assets/icons/contact.svg" class="contactImg">
</a>
<a class="projetos" routerLink="/">projects
<img src="../assets/icons/projects.svg" class="projectsImg">
</a>
<a class="sobre" routerLink="/">about me
<img src="../assets/icons/aboutme.svg" class="aboutMeImg">
</a>
<a class="skills" routerLink="/">soft skills
<img src="../assets/icons/soft.svg" class="softImg">
</a>
</nav>
<router-outlet></router-outlet>