Design comparison
Solution retrospective
Struggling with centering my component when its in desktop view.
Community feedback
- @BlackpachamamePosted 10 months ago
Greetings! you have done a great job š
š Some accessibility and semantics recommendations for your HTML
- To improve the semantics of your HTML, you can change your
<div class="attribution">
to a<footer class="attribution">
- The
attribution
should go outside themain
- In your styles, you have put
Body
instead ofbody
. In theory, this has no effect, but it is preferable for it to bebody
š Some suggestions
- You can use
object-fit: cover
in yourimg
, this will make the image fill the entire container maintaining its aspect ratio. More info - If your
parent-container
already has amargin
, thepadding
of yourbody
is unnecessary - Instead of using
margin
to center your content in the center of the screen, you can use theflexbox
properties in thebody
:
body { min-height: 100vh; display: flex; justify-content: center; align-items: center; font-size: 15px; font-family: var(--main-font); font-weight: var(--main-font-weight); background-color: var(--Very-dark-blue); /* padding: 3rem; */ flex-direction: column; gap: 20px; /* Separate the main from the footer */ }
- With these changes you no longer need a
margin-bottom
in yourparent-container
nor amargin-top
in thefooter
Marked as helpful0 - To improve the semantics of your HTML, you can change your
- @beniusisPosted 10 months ago
Hey š Good job on finishing the challenge! To answer your question, you can switch body property
height: 100%
tomin-height: 100vh
to center the component.Marked as helpful0@aymenthedeveloperPosted 10 months ago@beniusis i usually set the height to 100vh directly but i guess your suggestion is better, since it will not limit the height of the page to only 100vh if we add more content
Marked as helpful1 - @danielmrz-devPosted 10 months ago
Hello @J3r3mia!
Your project looks great!
Here's how you center the card:
- Apply this to the body (in order to work properly, don't use position or margins):
body { min-height: 100vh; /* don't use 100%, use 100vh */ display: flex; justify-content: center; align-items: center; }
I hope it helps!
Other than that, great job!
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