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 using html, css and bootstrap

@shubhanginisharma627

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


can anyone tell me how to center align the card? , I have to use measure again and again and it takes a lot of time. if anyone knows please tell me.

Community feedback

@kolehiyolo

Posted

the best suggestion I can give you is position:absolute. this is the one that is guaranteed to always keep your content in the center of the page.

.card{ position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); }

checkout this video for more info on the position attribute: https://www.youtube.com/watch?v=P6UgYq3J3Qs

0

@shubhanginisharma627

Posted

Thanks, I will try it

0
Steven Toben• 750

@steventoben

Posted

How are you trying to center the card? Along the y axis? or x axis? or both? There's tons of ways if you just want to center the card to the middle of the screen just create a div that wraps everything in the body. Make sure the width is 100vw and the height it 100vh. Then set the display to flex. set justify-content to center to center is horizontally, set align-items to center to center it vertically. Flexbox is probably overkill for this tho it could most likely be done simpler if you clarified what exactly you want to achieve.

0

@shubhanginisharma627

Posted

thanks for the advice

0
Nemanja• 60

@FriendlyCodeArt

Posted

You can try this : body { display: flex; justify-content: center; align-items: center; height: 100vh; }

0

@shubhanginisharma627

Posted

Thanks, I will try it

0
Tereza• 605

@sirriah

Posted

Hello, try to look at this article. https://moderncss.dev/complete-guide-to-centering-in-css/

0

@rogozinski

Posted

have you tried to use "margin: 0 auto;" for "body" selector?

0

@shubhanginisharma627

Posted

I have tried it didn't work.but thanks for the advice

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