Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

NFT Preview Card Component - Using CSS Flexbox

Ghaffar_b 240

@Ghaffar7

Desktop design screenshot for the NFT preview card component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


How can I style the image to display the icon-view.svg on the image while the section is active?

Community feedback

Elaine 11,400

@elaineleung

Posted

Hi Ghaffar,

To show the icon with the image when hovering on the image, you want to have a container for your image first that contains your image and also an overlay <div> like this, and within the overlay, you'll have your icon:

<div class="card__image">
   <img src="./images/image-equilibrium.jpg" alt="Equilibrium, a multicolor cube" />
   <div class="overlay">
      <img src="./images/icon-view.svg" alt="" class="">
   </div>
</div>

The overlay needs a position:absolute (which means the parent container also will need position:relative added). The CSS for the overlay can look something like this:

.card__image {
  position: relative;
}

.overlay {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 1;
  background-color: hsla(178deg, 100%, 50%, 0.5);
  opacity: 0;
  display: grid;
  place-content: center;
  transition: opacity 200ms ease-in-out;
}
.overlay img {
  width: 3rem;
  height: 2rem;
}
.overlay:hover {
  opacity: 1;
}

My solution is here if you want to check it out. Good luck!

1
Aman Dagne 120

@Amandagne

Posted

Great work. Can you explain your question?

0

Please log in to post a comment

Log in with GitHub
Discord logo

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