Design comparison
Solution retrospective
I’m really proud of this CSS code because I made it mobile responsive without using any @media queries.
h1 { font-size: clamp(2.2rem, 1.986rem + 0.571vw, 2.5rem); } .container { max-width: 1440px; margin: auto; padding: 2rem; display: grid; }
Using place-content: center, I was able to align and justify it both vertically and horizontally.
What challenges did you encounter, and how did you overcome them?.container { display: grid; place-content: center; }
The biggest challenge for me was not using @media, instead relying on relative units, and making sure everything was centered on the screen.
What specific areas of your project would you like help with?I’d like to know if this is actually the right way to do it to avoid using @media. Also, how can I improve my CSS writing skills?
Community feedback
- @kodan96Posted 5 months ago
hi there! ✌️
-
all content within the
body
tag should be wrapped inside milestones (header, main and footer HTML tags) -
don't use the 62.5% font size hack, it causes accessibility issues.
-
use rem or other relative units instead of pixels for font sizes or pretty much anything else.
-
don't apply
width
to your elements explicitly. if you want to determine the width of your element usemin-width
ormax-width
. you can even combine them withwidth
:
.element { width: 90%; max-width: 66rem; }
with this
.element
will take up 90% of the parent container's width, but when it reaches the 66rem in width it will stop expanding any furtherHope this was helpful 🙏
Good luck and happy coding! 🙌
Marked as helpful1 -
- @ijohnstPosted 5 months ago
First of all great work, you definitely got it working. To add on to the other comment you really don't need grid or flex on your container and you don't need the unnecessary divs you have throughout the HTML. All of these elements are going to be block elements so they will stack by default (you can see it if you write all the HTML and don't add CSS yet).
Wrap your
<img><h1><p>
in an<article>
and then let either some padding or margin handle the spacing.You can however use the grid, place contents trick on either your
<body>
or<main>
(if you choose to wrap it in that) to center the content. But inside the card you should avoid the divs and flex for now. You'll have plenty of opportunities to use them in the later challenges.Marked as helpful0
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