NFT preview challenge

Solution retrospective
In the active mood, I couldn't do the overlay with the icon inactive mood, I searched for a way but it didn't work. Does anyone have a way that will work?
Please log in to post a comment
Log in with GitHubCommunity feedback
- @AcmeGamers
Hey there 👋,
Congratulations on nearly completing the challenge 🥳! You did great on centring the whole
<main>
tag usingtransform
😊.I would recommend changing the paragraph color to a bit lighter tone so people with eye issues can read it with ease. As far for the issue of hovering on the image that you were having, we use
pseudo elements
for that, things like::before
,::after
,:first-child
, etc. However,pseudo elements
does not work on<img>
elements, so to cover that issue, we use the<div>
tag.Solution (Spoiler Alert)
HTML
- Change your
<img class='main-img'>
element to<div class='main-img'>
element - Yup, that's all for HTML! :D
CSS
Add a background image to the div
.main-img { background: url("images/image-equilibrium.jpg"); background-size: contain; min-height: 268px; width: inherit; // Inherits the available width border-radius: 20px; }
Let's add the pseudo
:before
state on the div element.main-img::before { content: ""; // This is important, it won't work without it display: block; height: inherit; // Inherits the div height width: inherit; // Inherits the div width background: red; opacity: 0.6 }
If you reach here, it means you may have got a complete red square on your NF T image. But the question is, we want it to appear when it hovers, so try doing some research on
how to add hover on ::before
, if you figure it out, congrats, you are moving at a fast pace! :DDDIf it still confuses you, drop a reply and I will be here to explain it with an easier method 😊. Hope to see your future success and designs, until then, best of luck!
Marked as helpful - Change your
Join 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