Design comparison
Solution retrospective
Tried not using fixed widths and heights as much. Still need to figure out the best use-cases for both flex and grid in these types of designs. Seems a combination worked for now. Was there a more efficient way I overlooked?
The top image had some overflow issues I couldn't seem to fix except for (in my opinion) bruteforcing it with a 'overflow: hidden' on the parent, which doesn't seem ideal.
I still feel like I design these things in a more roundabout way than necessary, so if anyone could share any insights, that would be great!
Community feedback
- @vanzasetiaPosted over 1 year ago
Hi, Ferdi Tondeur! ๐
In general, you should use flexbox for one direction layout either column or row. You should use the grid for two dimensions layout. Meaning, the layout requires the column and the row to be controlled.
In this case, you make the
<body>
element as a flex container to put the card in the middle of the page.For the
<main>
element or the card element, you only need to set amax-width
to prevent it from filling the entire page on large screen sizes. So, you should removemin-width
,min-height
, andmax-height
.For the height of the card, let the content controls the height of it.
For the illustration image, it will be overflowing because the
<span>
is larger than the parent elementโthe<main>
elementโbecause of theborder-radius
. You are already doing great by settingoverflow: hidden
on the parent element.But, I recommend making the illustration a "real" image element. This way, you don't have to set
height
and other background properties. In other words, you will end up with less code.Also, you should rarely set any
width
orheight
. That does not mean you are using dynamic units such as percentages or viewport units, you can use them very often. I think the golden rule of responsive design is to let the content controls the size of the element whenever possible.I hope this helps. Happy coding! ๐
Marked as helpful0 - @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.
HEIGHT ๐:
- Use
min-height: 100vh
forbody
instead ofheight: 100vh
. Setting theheight: 100vh
may result in the component being cut off on smaller screens.
- For example; if we set
height: 100vh
then thebody
will have100vh
height no matter what. Even if the content spans more than100vh
.
- 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!
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