Responsive Profile Card Component Challenge using Flex
Design comparison
Solution retrospective
My first challenge! New to frontend dev and excited to be learning new skills everyday.
The only thing I couldn't resolve was how to integrate the images pattern in the mobile view. The problem I had was that when I switched to mobile view, the card component didn't get centered. I worked around this problem by none displaying the patterns in mobile view.
Any clues in why I'm getting this issue?
Thanks in advance!
Community feedback
- @Timothy1982Posted almost 4 years ago
On my desktop the card is also not centered. My suggestion would be to give the body a min-height of 100vh and display flex. Then you can center it with justify-content and align-items.
The top and bottom background images could then be set using ::before and ::after. You could the remove the two divs "top" and "bottom".
I would also suggest not using position: absolute on your card plus you don't need it when you center it with flexbox (like mentioned above).
You could add the following styles to your body:
body { display: flex; justify-content: center; align-items: center; min-height: 100vh;
On you card class remove:
position: absolute; top:... left:.. transform:..
and add
position: relative;
That will fix your problem with the card header image. And if you have removed the two divs with the background images, all should look nice and centered.
From there you should get it done with ::before and ::after on the background images. Let me know if you have problems.
Me or someone else will probably help you out (or in slack).
1 - @sportiz91Posted over 3 years ago
Thanks for the detailed answer. That was really helpful to me!
0
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