I want to add an hover effect to my links like this one: https://codyhouse.co/ds/components/app/related-articles
I’m using the following CSS code for that:
a.headline h3:hover {
background-size: 100% 100%;
}
a.headline h3 {
color: $body-color;
background-repeat: no-repeat;
background-image: linear-gradient(transparent 50%, rgb(228, 227, 255));
background-size: 0% 100%;
will-change: background-size;
transition: background-size 0.3s ease-in-out;
}
Unfortunately the result is not the same as in the example.
Is there some kind of JS code or is there an error in my CSS?
Here’s a working demo: https://codepen.io/cray_code/pen/poOQJjX
2
Answers
In the example, it is done the opposite. The
a
nested in theh3
. This works becausea
is inline by default. You can fix this with your structure by settingh3
todisplay: inline;
.Try this: