Pixel-perfect card component with 3d hover effect
Design comparison
Solution retrospective
Hello!
I used a Firefox extension, 'Pixel Perfect Pro', to get the website to match the design. It's a pretty great tool that I recently discovered.
This was a simple challenge, and good for practice as well. I added a neat little 3d hover effect to the card using Javascript (props to Apple Pie Giraffe for inspiration)
Please check it out and leave your feedback!
Community feedback
- @ApplePieGiraffePosted over 3 years ago
Greetings, Syed Ali Mansoor! ๐
Amazing job on this challenge! ๐ You've done a great job in matching the design preview for this challenge (as you mentioned) and the 3D hover state that you added to the card is pretty awesome! ๐ Everything else looks good and responds well! ๐
(And thanks for the mentionโthat's encouraging and happy for me to hear! ๐ )
Of courseโkeep coding (and happy coding, too)! ๐
1 - @akshay63Posted over 3 years ago
Hey @Syed Ali Mansoor! Great effects, there. I loved it๐๐. Thanks for sharing your solution. I'm too learning a lot from APG. Btw how did you achieve the hover effect though?
1@syedalimansoorPosted over 3 years ago@akshay63 Thanks!
Check out the README file, I have added an explanation in there.
You basically add a "mousemove" event listener to the element, in which you get the position of the mouse cursor, and then you get that position as a percentage of the width/height of the element.
You use this percentage to rotate the card on the X and Y axes. In my example I wanted the card to rotate no more than 30deg on both axes, so I did this:
rotateY = xPercent * 30; rotateX = -(yPercent * 30);
It's a bit complicated but we got this ๐ช๐ค
0 - @coreyhclayPosted over 3 years ago
you've got an extra space between "12m" and "+". this solution is x1000 better than mine, i'm learning a lot from your repository, thanks
1@syedalimansoorPosted over 3 years ago@coreyhclay Oops, thanks for the heads up. Small details like these are key to making a good website.
Thanks for the compliment as well and happy coding!
1
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