Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Pure HTML and CSS - Need help with best "flow" practices

@Paulo-Dandrea

Desktop design screenshot for the Product preview card component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

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-Zubiri

Posted

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 helpful

1

@Paulo-Dandrea

Posted

Thx! It helped! @Leo-Zubiri

0

@0xabdulkhaliq

Posted

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 for body 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 for body instead of height: 100vh. Setting the height: 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 the body will have 100vh height no matter what. Even if the content spans more than 100vh of viewport.
  • But if we set min-height: 100vh then the body will start at 100vh, if the content pushes the body beyond 100vh it will continue growing. However if you have content that takes less than 100vh it will still take 100vh in space.

.

I hope you find this helpful 😄 Above all, the solution you submitted is great !

Happy coding!

1

@Paulo-Dandrea

Posted

@0xAbdulKhalid for the thoughtful response. It is exactly what I needed.

0

@0xabdulkhaliq

Posted

@Paulo-Dandrea Glad you found it helpful ! 🤠

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join 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