Skip to content
  • Learning paths
  • Challenges
  • Solutions
  • Articles
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 4 years ago

profile card component using html, css and bootstrap

Shubhangini Sharma•130
@shubhanginisharma627
A solution to the Profile card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

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.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Tristan Sean Paul Perfecto Cinco•45
    @kolehiyolo
    Posted over 4 years ago

    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

  • Steven Toben•750
    @steventoben
    Posted over 4 years ago

    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.

  • Nemanja•60
    @FriendlyCodeArt
    Posted over 4 years ago

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

  • Tereza•605
    @sirriah
    Posted over 4 years ago

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

  • Michal Rogozinski•50
    @rogozinski
    Posted over 4 years ago

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

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
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub