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 card component

anna 80

@skulbas

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


Question: is there a better way of positioning an icon over an image than calculating top/bottom and left/right percentages? Like, I'm sure there is, but it seems that I didn't learn about it yet.

Community feedback

@SinisaVukmirovic

Posted

Hello!

Yes! Yes there is a better and a correct way to position icon to always be in 50%.

First, you get the icon at 50% with

.icon {
  left: 50%
}

...and since the coordinate of any element start at 0, 0 which is at top - left corner, you need to shift the icon itself by 50% of itself dimensions, with

.icon {
  left: 50%;
  transform: translateX(-50%);
}

Ofc, values for the Y axis need to be added, in the same way as for X axis.

Hope I made this understandable.

If not, check out this article on translate property

Good luck in fixing your code!

Marked as helpful

0

anna 80

@skulbas

Posted

@SinisaVukmirovic Oh thank you so much!

1

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