Design comparison
Solution retrospective
Hey, i had problem adding the hover function please i woud appreciate comment on how to acheive that. let me know what you also think generally. how can i improve writting code in the rightful way.
Community feedback
- @lucaliebenbergPosted over 1 year ago
Hey @kingchoffy,
To achieve the hover effect, you need to put a
<div>
below the image, and wrap the image and the<div>
in another<div>
, an example would be:<div className="card__container">
<img src="NFTImage" alt="card image" />
<div className="overlay"></div>
</div>
You then need to make the overlay
<div>
position:absolute
and the image position:relative. This will remove the overlay<div>
from the DOM. Settop:0 and left:0
, this will make the overlay<div>
appear on top of the image.Here is an example of how I achieved it the end goal:
.card__top_wrapper { position: relative; } .card__top_image { position: relative; margin-top: 1rem; height: 302px; width: 302px; } .overlay { position: absolute; height: 302px; width: 302px; background-color: white; opacity: 0; border-radius:10px; top: 0; left: 0; margin-top: 1rem; transition: all 0.2s ease-in-out; } .overlay:hover { background: radial-gradient(50% 50% at 50% 50%, rgba(0, 255, 248, 0) 0%, #00FFF8 100%); opacity: 50%; cursor: pointer; }
I hope this helps. For other hover effect - where it changes to Equilibrium #number on hover, you will need to:
Write the NFT number in a
<p>
element, and within that<p>
element you must place a<span>
element, like so:/* html */
<p><span className="extra">Equilibrium </span>#3117</p>
/css/
.extra { display: none; } p:hover .extra { display: inline-block }
Note: you probably will be able to do it withdisplay: inline-flex
, instead of inline-block.I hope this helps 👌
Marked as helpful0@kingchoffyPosted over 1 year ago@lucaliebenberg Hello thank you for taking the time out to reply. from the example you provided i was able to get it to work :), it was helpful.
although i had to make some changes to make the overlay fit on the div, i messed around with the top and left property.
0
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