Design comparison
SolutionDesign
Solution retrospective
Overlay I didn't know how to create an overlay to an image, this is the approach that I took.
Since this was a link I used a <a>
tag as a container, because I thought when you click at the image it will take you to another page with more details of this NFT.
<a href="#" class="card__url-container"> <img src="./images/image-equilibrium.jpg" alt="A transparent cube balanced in one of its corners in a dark blue background promoting balance and calm" width="604" height="604" class="card__img" /> <div class="overlay"> <img src="./images/icon-view.svg" alt="" aria-hidden="true" /> </div> </a>
.card__img {
border-radius: 0.5rem;
}
.card__url-container {
position: relative;
}
.overlay {
position: absolute;
background-color: var(--clr-primary-500);
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
display: grid;
place-items: center;
border-radius: 0.5rem;
opacity: 0;
transition: 0.4s ease;
}
.card__url-container:hover .overlay {
opacity: 1;
background-color: var(--clr-primary-500-op);
}
Community feedback
- @mixchexPosted almost 2 years ago
Hi Brayan,
This looks and feels really nice.
Your approach for the overlay is good. Another alternative could be using the
:before
or:after
CSS pseudo-elements for your anchor and positioning it absolutely and making it visible on hover.Overall it came out really well, so well done.
Hope that helps.
Mike
Marked as helpful0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord