Design comparison
Solution retrospective
I was able to use flexbox to arrange the items how I wanted to. In the future I would consider using CSS grid and a framework like Tailwind CSS.
What challenges did you encounter, and how did you overcome them?I didn't know how to change the design of the page for different devices, so I did a quick search and learnt about media queries in CSS. I also had some issues sizing the categories button using flexbox, so again I did some research and realised I could just change the display mode to inline-flex.
What specific areas of your project would you like help with?Am I using Flexbox to the best of it's abilities? I feel like the way I've structured the HTML and used Flexbox is inefficient, and would love some pointers or tips to improve how my code is structured.
Community feedback
- @ShivangamSoniPosted 5 months ago
Nice Solution, but there are a few areas where improvements can be done.
Unnecessary use of Flex, With & Height
For the Category Tag, you are using many CSS properties, whereas the desired result could have been achieved in an easier way. This is your code for the category
.post-category { display: inline-flex; width: 82px; height: 29px; border-radius: 0.25em; background-color: var(--yellow); justify-content: center; align-items: center; font-weight: 800; }
This is how you could have taken advantage of the fact that the tag is a flex-child:
.post-category { align-self: flex-start; padding: 0 0.75rem; border-radius: 0.25em; background-color: var(--yellow); font-weight: 800; }
What I did is used the
align-self
property to align the element to the start of the parent flex-box. Secondly, I'm using padding to adjust the spacing required around the text.Default Styling
Another point to notice is that in many places you haven't adjusted the default padding & margin of elements like body, h1, p, etc. Because of this, there is an uneven spacing within the card.
You might want to look into CSS Resets, where we write some CSS that resets some of the default styling applied by the browsers. This is done because you will usually have your own styling needs, especially in case of Padding & Margin. So resetting some of the default properties just makes sure that no default styling affects our design.
Semantic Tags
I also recommend you to look into Semantic Elements & replace the
divs
with Semantic Elements instead. Read More about Semantic HTMLMarked as helpful1
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