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
Desktop design screenshot for the Order summary component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Community feedback

@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!

0
P

@radektomasek

Posted

Hello Eduardo 👋,

I had some time in my morning and had a look at your solution. It looks great, well done. 👏

Here are my few observations/recommendations for tweaks you can make to simplify your structure even more:

Simplifying the Flex structure

You have two containers informations and music-price both set as display:flexbox. My understanding is that you are using for to display the icon and the price container. It does the trick, but you can simplify it by having one flexbox container with three children.

  • The parent in your case will be the container .informations
  • The first child will be the logo (icon music).
  • The second child will be the flex (colunn) container with the anual price.
  • The third child will be the change button.

The you can use flex-basis for each child to set an appropriate width. On top of that, you can also use gap for the parent, but in this case it's not necessary.

Therefore, your code will look something like this (please be mindful of comments, these are just some non-standard HTML as I wasn't able to put classic ones for you to see):

# Flex container
<div class="informations">
# Flex child 1
<img src="images/icon-music.svg" alt="icon music">
# Flex child 2
<div class="price">
<strong>Annual Plan</strong>
<span>$59.99/year</span>
</div>
# Flex child 3
<a href="#">Change</a>
</div>

If you slightly update the CSS like this, you will get the same result as you have now (minus that removed element .music-price which we don't need). The CSS might look like this:

main .informations {
display: flex;
align-items: center;
justify-content: space-between;
margin: 2rem 0;
background: hsl(225, 100%, 98%);
padding: 1.5rem 1rem;
width: 100%;
border-radius: 0.8rem;
}

main .informations .price {
display: flex;
flex-direction: column;
}

main .informations a {
color: hsl(245, 75%, 52%);
font-weight: 600;
font-size: 90%;
transition: all 0.3s;
}

main .informations img {
width: 3rem;
height: 3rem;
}

If you go even further, you can remove the justify-content: space-between from the flex parent and this will put all the elements close to each other. Then you can add a gap: 1rem to your Flex parent, which makes things more spread. (Flex gap is a very useful property).

The last thing is to extend the flex basis for the second child and this will make your whole thing look closer to the design. (I also added an extra CSS selector for aligning the text to the left)

main .informations {
display: flex;
align-items: center;
margin: 2rem 0;
background: hsl(225, 100%, 98%);
padding: 1.5rem 1rem;
width: 100%;
border-radius: 0.8rem;
gap: 1rem;
}

main .informations .price {
display: flex;
flex-direction: column;
flex-basis: 8rem;
}

main .informations a {
color: hsl(245, 75%, 52%);
font-weight: 600;
font-size: 90%;
transition: all 0.3s;
}

main .informations img {
width: 3rem;
height: 3rem;
}

main .informations .price span {
text-align: left;
}

I hope it makes a sense. It's a small tweak relatively, but it will simplify the structure quite a bit.

general improvements tips

  • You should also consider using CSS variables for repeating elements (colors, fonts). More info here
  • You might consider using mobile first design. Start constructing your design from the smaller displays to larger ones. I think it might be easier to reason about it (but it's primarily a matter of preference). I feel for these challenges it's the perfect approach. Advantages/Disadvantages
  • The correct way how to setup a border-box is this (you can find more info here):
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}

But in general, the solution looks really good. And was happy to review it 👍

Have a wonderful day.

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