Design comparison
Solution retrospective
The most difficult part was center a div.
And i think i use best practice in css but no in html.
Community feedback
- @nmnjnklcPosted about 2 years ago
Hello @AldoRdz2001,
I think the easiest way to center a div (or any element) is to set the following properties to its parent element. For this particular situation:
body { height: 100vh; display: flex; align-items: center; justify-content: center; }
Hope this helps.
Stay safe and happy coding!
Marked as helpful2@AldoRdz2001Posted about 2 years ago@nmnjnklc Thank you for your comment, i save this for the next project
0 - @MelvinAguilarPosted about 2 years ago
Hi @AldoRdz2001 ๐, good job completing this challenge, and welcome to the Frontend Mentor Community! ๐
I like this solution for the challenge. Here are a few suggestions I've made that you can consider in the future if you're looking to improve the solution further:
- The GitHub repository is private, so only you can decide who can see your code and review it.
To improve your HTML:
- It's recommended to use the semantic tag main. Click here for more information.:
<body> <main class="container"> . . . </main> <footer> . . . </footer> <body>
- Add an h1 tag to your solution. The
<h1>
element is the main heading on a web page. There should only be one<h1>
tag per page, and always avoid skipping heading levels; Always start from<h1>
, followed by<h2>
, and so on up to <h6> (<h1>,<h2>,...,<h6>). The HTML Section Heading elements (Reference)
<h1 class="contenedor__contenido--bold">Improve your front-end skills by building projects</h1>
Here are some other suggestions:
- There are two modern CSS techniques to center elements:
Using flexbox layout:
body { width: 100%; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; }
Using grid layout:
body { width: 100%; min-height: 100vh; display: grid; place-content: center; place-items: center; }
Additionally, remove the margin to center the "contenedor" correctly.
Links with more information:
- The Complete Guide to Centering in CSS.
- A Complete Guide to Flexbox (CSS-Tricks).
- How TO - Center Elements Vertically (W3Schools).
- CSS Layout - Horizontal & Vertical Align (W3Schools).
I hope those tips will help you.
Good job, and happy coding!
Marked as helpful1@AldoRdz2001Posted about 2 years ago@MelvinAguilar Thank you for all the tips, i added the remomendations, thank you a lot
1
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