Design comparison
Solution retrospective
I had trouble with using CSS, when to use px, vh, or %
Community feedback
- @fizasaif123Posted about 1 year ago
Use px for fixed-size elements and precise control. Use % for relative sizing within parent containers in responsive layouts. Use vh and vw for elements that should scale with the viewport size in responsive designs.
2 - @george5-starPosted about 1 year ago
Congratulation Steven for completing the project and I hope you had fun building it. Regarding you question on which unit to use I recommend the using rem or em which is explained in the code samples below:
<div> <h1>Some text</h1> </div>
h1 { padding: 1em; // which is equal to 16px and it is relative to its parent div. } h1 { padding: 1rem; // this is relative to the root element which is the html tag. }
So I recommend using em for paddings and margins and rem for font-sizes. Also this link will provide you with a brief overview on them.
1
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