Responsive Recipe page using CSS flex

Solution retrospective
I'm proud of how structured and efficiently I could think and code. Definitely practice makes perfect.
What challenges did you encounter, and how did you overcome them?Following are the challenges I faced:
- Image alignment and fitting it in the recipe card
- Making the page responsive
How did I encounter?
- Made the image margins auto and gave it a max-width
- Studied media query
- When to use % and when to use px, vh etc?
- Is there any standard way where i can learn to write neat code?
Please log in to post a comment
Log in with GitHubCommunity feedback
- @ippotheboxer
Hello, nice work with this project! The components on the recipe scale well responsively. Here are some tips!
At full screen size, the recipe is not in the center of the page. I would recommend using flexbox to center and position divs. For example, on main in styles.css, you could add the following css properties:
display: flex; justify-content: center;
This will align it in the horizontal center of the page, which means you don't have to set margins and width to position it in the center. Regarding use of %, px and vh:
VH: viewport height is usually used on the main container (e.g. body or main) and it is usually set as
min-height: 100vh;
to ensure it takes up the whole screen.px: Using pixels is usually best for setting font sizes or image width/height. You can use media query to change pixel sizes at different viewport sizes.
Percentage: this is usually best for ensuring a div or element on screen only takes up a certain amount, for example with your component you could make it so that the img takes up 100% width, and then apply margin around.
You also shouldn't set min or max widths to the body, but rather the custom div components such as the recipe component.
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