I'm trying to implement underlying on image on hover link and image.
Here is what try to achieve:
The issue is when I hover on element I see two lines but should be one on hover both link and image, also two underlines are visible during window resizing and are not stable. Maybe there is a better way to handle that?
Here is my code:
.lnk-underline {
text-decoration: none; /* Remove default underline for text */
position: relative;
display: inline-block;
}
.lnk-underline::before {
content: "";
position: absolute;
left: 0;
bottom: -1.5px;
width: 100%;
height: 2px;
background: #D0191D;
}
.underline-hover {
text-decoration: none;
position: relative;
display: inline-block;
}
.underline-hover::before {
content: "";
position: absolute;
left: 0;
bottom: -1.5px;
width: 100%;
height: 2px;
background: #D0191D;
transform: scaleX(0);
transform-origin: bottom;
transition: transform 0.3s ease-in-out;
}
.underline-hover:hover::before {
transform: scaleX(1);
}
/* Remove underline from lnk-underline for downloadLink on hover */
.lnk-underline:hover {
text-decoration: none;
}
<div class="underline-hover">
<a href="@Url" class="lnk-underline" id="downloadLink">
Download
</a>
<a href="@Url" id="iconDownload">
<img src="/icons/download.svg" />
</a>
</div>


I will do that this way ...
<a href...divparent.Less code is always more easier for understanding...