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

Use of Flexbox, negative margins and relative absolute positionings.

@srijan-srijan

Desktop design screenshot for the Profile card component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


I pretty much enjoyed coding this design.

However, when placing the center image, I opted to use negative margins.

Is there a standard way to achieve such scenarios that I am unaware of?

Community feedback

@SasaVatic

Posted

You can set parent div of img to be position: relative and img to be position: absolute then use property left: 50%; on img. It will add gap between parent div left edge and picture left edge exactly 50% of parent div width. Now to finally center img horizontally use transform: translateX(-50%) to move picture to left for half it's width. To position img vertically simply use top: property on img element;

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