I want a background color transition on my anchor tags that goes from left to right whenever I hover upon them but the background is not visible, instead an underline is only visible.
.project a {
font-size: 27px;
text-decoration: none;
position: relative;
color: rgb(190, 190, 190);
display: inline-block;
overflow: hidden;
}
.project a::after {
content: '';
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 3px;
background-color: #3498db;
transform: scaleX(0);
transform-origin: right;
transition: transform 0.3s ease;
}
.project a:hover::after {
transform: scaleX(1);
transform-origin: left;
}
.project a:hover {
color: rgb(240, 240, 240);
}
This is the CSS I’ve used for my anchor tag. There is no other CSS for the anchor tags in the entire file.
I tried to implement the animation without pseudo elements, I tried keyframes but the animation I wanted was only possible with pseudo elements. The animation is working as I can the my desired animation to occur as an underline under the anchor tags, but I want the animation of the background to be visible.
2
Answers
In order to make the background animation visible, you can try instead of using the ::after pseudo-element, you can utilize the ::before pseudo-element for the background animation.
this is my code and check this and let me know your situation.