Not Found
Not Found
Not Found
Not Found
Not Found
Request path contains unescaped characters
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 FLEXBOX | GRID

@AltairCGS

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


If someone can help me so that the "view" image (the eye of the image that appears when the cursor is positioned over the image) does not lose opacity when applying the hover to the image, I would greatly appreciate it.

<div class="container">
        <img src="images/image-equilibrium.jpg" alt="NFT" class="image" />
        <div class="overlay">
          <div class="text">
            <img src="images/icon-view.svg" alt="" />
          </div>
        </div>
</div>

I am open to feedback.

Community feedback

Chris 180

@chrizgx

Posted

Hey! I think there is a much simpler solution to your problem with just 2 lines of code. The reason why opacity is being applied to the eye icon is that you apply opacity on the whole div.overlay, which includes the eye image. What you can do instead, is simply replace the HSL(178, 100%, 50%) background color with the equivalent RGBA #00fff760. It's the same color, except that opacity is applied to the background-color itself and not the whole div element.

After that, change .overlay:hover to {opacity: 1}

O had the exact same problem, that's the solution I used too. You can see the outcome here: https://chrizgx.github.io/frontendmentor-nft-preview-card-component-main/

And the code too: https://github.com/chrizgx/frontendmentor-nft-preview-card-component-main/

Feel free to ask anything, I'm happy to help

Marked as helpful

1
yishak abrham 2,150

@yishak621

Posted

First position the card-img(nft) as relative and overflow hidden

.card-img { 
   overflow: hidden; 
   position: relative; /*!important*/ 
 }

Then add both the view img and card overlay color as a background ....since we assign the card-img relatively position now we assign the overlay absolute position [the overlay will streach to cover the card-img area not more than that ....thats the whole concept for the absolute and relative position in here]...to center the icon-view image i use flex ...finally i put opacity 0 because we want to appear the overlay when we hover over the card-img

.card-overlay { 
   display: flex; 
   position: absolute; /*!important*/ 
   border-radius: 7px; 
  
   align-items: center; 
   justify-content: center; 
   flex-direction: column; 
  
   top: 0; 
   left: 0; 
   width: 100%; 
   height: 100%; 
   background-image: url(./images/icon-view.svg) no-repeat center; 
   background-color: hsl( 
     178, 
     100%, 
     50%, 
     0.5 
   ); /*0.5 is opacity of color to enable transparency*/ 
   opacity: 0; 
   transition: ease-in-out 0.8s; 
 }

Finally when hover ,i add opacity 1


```.card-overlay:hover { 
   opacity: 1; 
   transition: ease-out transform 0.8s; 
 }

Marked as helpful

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