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

Profile card component

Adam 210

@AdamMintaj

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


One thing I wasn't sure about here was how to make the profile picture always center on the verge of the card's bubbly background image. Finally I set the picture's top margin to be relative to the card's width but I'm sure it's not the driest solution since I had to adjust it with media queries anyway. I'm wondering now if it wouldn't be better to just go with fixed values in pixels on everything in the first place. I'd appreciate if anyone put their two cents in on this dilemma Edit: thanks to Ahmed-Elsayed I realised I have overcomplicated things unnecessarily and have already fixed that

Community feedback

Ahmed 150

@Ahmed-Elsayed-projects

Posted

Hello @AdamMintaj, -One way to do what you want and avoid media queries is to put the user information section and card's background inside a flex container. Then set each of them to flex:1; which will make them share the height in half. From here you can use two way to center the image:

  1. Center the image horizontally with text-align: center;. Then center the image vertically by setting negative margin with half of the image height/width(doesn't matter since it's square-shaped) which in that case is margin-top: -48px;.
  2. Use position: relative; on the information section. Then add this to the image position:absolute; left: 0 transform: translate(-50%, -50%) /*centers the image horizontally and vertically*/ Personally I do prefer the first method because I don't have to add margin padding-top to the information section(to prevent overlapping). Here's a link for my solution: https://www.frontendmentor.io/solutions/flexbox-and-background-styles-WL9A0tbLRn . Hope it helps

Marked as helpful

0

Adam 210

@AdamMintaj

Posted

@Ahmed-Elsayed-projects thanks a lot for your advice. You actually made me realise I totally overcomplicated the whole thing when it could be done so easily, thanks for that a lot. I will definitely change that. I also let myself check how you did the same challenge and I saw you put the scores in an unordered list. Since I just went with divs, I'm wondering why did you decide to use a list? What are the advantages of using a list here?

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