Design comparison
Solution retrospective
I had an issue not getting the container to stay in the middle, there for if you shrink the page it will not stay centered until it reaches 500px
Community feedback
- @denieldenPosted almost 2 years ago
Hello Deeem, You have done a good work! 😁
Some little tips to improve your code:
- add
main
tag and wrap the card for improve the Accessibility - also you can use
article
tag instead of a simplediv
to the container card for improve the Accessibility - you can use
picture
tag to change image by resolution -> read here but the best way is just put more specific background properties to the body like this:
background: url("../img/pattern-background-desktop.svg") no-repeat top center; background-size: contain; background-color: #e0e8ff;
- centering a
div
withabsolute
positioning is now deprecated, it uses modern css likeflexbox or grid
- use flexbox to the body to center the card. Read here -> best flex guide
- after, add
min-height: 100vh
to body because Flexbox aligns child items to the size of the parent container - use
min-height: 100vh
to body instead ofheight
, otherwise the content is cut off when the browser height is less than the content - instead of using
px
use relative units of measurement likerem
-> read here
Keep learning how to code with your amazing solutions to challenges.
Hope this help 😉 and Happy coding!
Marked as helpful0 - add
- @HassiaiPosted almost 2 years ago
To center the content on a page, specify the following inn the body: body {min-height:100vh; display: flex; justify-content: center; align-items: center;} or body {min-height:100vh; display: grid; place-items: center;}. No need to use position to center the content. No need for the transform as well. Use rem and as unit for the padding, margin and font-size values. preferably use rem for the font-size. by default 1rem or em= 16px. Hope am helpful HAPPY CODING
Marked as helpful0@Deem1203Posted almost 2 years ago@Hassiai
I am quite new to this so I'm always getting stuff wrong haha, I found centering with the top:, left: and transform works and I got into a habit of it. I appreciate your help!
0 - @tchytechPosted almost 2 years ago
This looks good for a start. Just keep practicing. Practice makes you a master in the act. @Hassiai
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