Pure HTML and CSS - Need help with best "flow" practices
Design comparison
Solution retrospective
Could you help me with HTML and CSS best practices like:
- 'Flow layout'. I want to be responsive but not hard-coding the size of the card, etc.
- Did I use the most smart way to cascade properties?
- Did I use the correct elements?
Thx!
Community feedback
- @Leo-ZubiriPosted over 1 year ago
Hi, nice solution. If you want to have the same space between sections in the card you can use flex: 1 in each container. Also you can use grid (I prefer it for this cases):
.card{ display: grid; grid-template-columns: repeat(2,1fr); }
Just verify in the card are two main sections
<div class="card"> <div> </div> <div> </div> </card>
You can change the column size in grid, for example 3 columns:
grid-template-columns: 1fr 2fr 1fr;
In case of media queries:
A common config:
@media(min-width: 480px){ /* From a cell phone to a bigger screen*/ } @media(min-width: 768px){ /*From a tablet to a larger screen*/ } @media(min-width: 1140px){ /* From a laptop to a larger screen */ } @media(min-width: 1400px){ /* more...*/ }
You always focus in mobile view and use a break point(media querie) to change the distribution, example:
.product_card{ display: grid; grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; } @media screen and (min-width: 480px){ .product_card{ grid-template-columns: 1fr 1fr; } }
Marked as helpful1 - @0xabdulkhaliqPosted over 1 year ago
Hello there 👋. Congratulations on successfully completing the challenge! 🎉
- I have other recommendations regarding your code that I believe will be of great interest to you.
BODY MEASUREMENTS 📐:
- The
width: 100%
property forbody
element is not necessary. because it's a block level element which will take the full width of the page by default.
- Use
min-height: 100vh
forbody
instead ofheight: 100vh
. Setting theheight: 100vh
may result in the component being cut off on smaller screens, such as mobile devices in landscape orientation.
- For example; if we set
height: 100vh
then thebody
will have100vh
height no matter what. Even if the content spans more than100vh
of viewport.
- But if we set
min-height: 100vh
then thebody
will start at100vh
, if the content pushes thebody
beyond100vh
it will continue growing. However if you have content that takes less than100vh
it will still take100vh
in space.
.
I hope you find this helpful 😄 Above all, the solution you submitted is great !
Happy coding!
1@Paulo-DandreaPosted over 1 year ago@0xAbdulKhalid for the thoughtful response. It is exactly what I needed.
0@0xabdulkhaliqPosted over 1 year ago@Paulo-Dandrea Glad you found it helpful ! 🤠
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