@UnTalPeluca
Posted
Hi, I've been reading your code and it's very clean, I'm sure you'll do well in the future when you use tools like scss. In these cases I like to use ::before and ::after, to do so you have to wrap your img.card-image in a div, because these pseudo-elements don't work in imgs. Here is an example where I use ::before to create an element that is the same size as the image, has two backgrounds, and uses ::hover to make it visible.
.card-image-wrapper {
cursor: pointer;
position: relative;
border-radius: 1rem; /* with this we don't have to specify */
overflow: hidden; /* the border radius on each element.*/
}
.card-image-wrapper::before {
content: "";
position: absolute;
width: 100%;
height: 100%;
transition: opacity 0.4s ease-in;
background: url(./images/icon-view.svg) no-repeat center, rgba(0,255,255, 0.5);
opacity: 0;
}
.card-image-wrapper:hover::before {
opacity: 1;
}
.card-image {
width: 100%;
display: block; /* When an image is inside a div,
the div use an extra empty space at the bottom,
this solves it */
}
Marked as helpful
@eerolli
Posted
@UnTalPeluca This worked a treat, thank you very much.