Design comparison
SolutionDesign
Solution retrospective
Is the centering and responsiveness well done?
Community feedback
- @danielmrz-devPosted 10 months ago
Hello @KhDyanne!
Your project looks great!
- Using
margin
is not the best option to center an element. Here's a very efficient (and better) way to place an element in the middle of the page both vertically and horizontally:
š Apply this to the body (in order to work properly, don't use position or margins):
body { min-height: 100vh; display: flex; /* it works with grid too */ justify-content: center; align-items: center; }
I hope it helps!
Other than that, great job!
Marked as helpful1 - Using
- @BlackpachamamePosted 10 months ago
š Some accessibility and semantics recommendations for your HTML
- To improve the semantics of your HTML, you can change your
<div class="container">
to a<main class="container">
and the<div class="attribution">
to a<footer class="attribution">
- The
attribution
should go outside themain
š Some suggestions
- Add a
padding
to generate interior space on your card. This prevents you from usingmargin
orpadding
on child elements to achieve the same result - Use
min-height
andmax-width
, this will help the content stretch or shrink if you need to. Unlikeheight
andwidth
which can cause your content to be cut off on certain screens. For example, usemin-height: 100vh
instead ofheight: 100vh
- Apply
max-width: 100%
to yourimg
so that it occupies the correct width within the container - I think that the
img
of the banner does not occupy the corresponding width because you applied aheight: 370px
, at least on desktop screens, this causes the borders to not be seen correctly. To solve it, you could leave theheight: auto
, addmax-width: 100%
- Instead of using
margin
to center your content in the center of the screen, you can use theflexbox
properties in thebody
:
body { background-color: rgb(223, 223, 237); /* margin: 15% auto 15% auto; */ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; min-height: 100vh; display: flex; justify-content: center; align-items: center; flex-direction: column; gap: 20px; /* Separate the main from the footer */ }
- Correct and add the following to your
card
class:
.card { min-height: 400px; max-width: 320px; padding: 16px; text-align: center; background-color: white; box-shadow: 2px 2px 2px 1px rgb(0 0 0 / 20%); } h4 { /* padding: 0 10px 0 10px; */ margin-block: 15px; color: rgb(18, 18, 77); font-weight: bold; font-size: 23px; }
Marked as helpful1 - To improve the semantics of your HTML, you can change your
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