QR- code card with description in html and css
Design comparison
Solution retrospective
HTML/CSS Centering Feedback Request
What did you find difficult while centering the <div>?
I found it challenging to [describe the specific challenge, e.g., vertically center the div]. The approach I took was [briefly describe your approach], but I'm open to suggestions on a more effective method.
Which areas of your HTML/CSS code are you unsure of?
I'm unsure about the [specific code snippet, e.g., CSS flexbox properties] I used for centering. I would like feedback on whether this is a recommended approach or if there's a better way to achieve the same result.
Do you have any questions about best practices for centering elements?
I'm interested in learning more about best practices for centering elements in CSS. Are there any recommendations or considerations I should be aware of based on my current implementation?
Here's a snippet of my code for reference:
<!-- Your HTML code here --> <div class="centered-div"> <!-- Content goes here --> </div>
.main-div { background-color:hsl(0, 0%, 100%) ; width: 30%; margin: 60px auto; padding: 20px; border-radius: 15px; }
Community feedback
- @0x-UGPosted 12 months ago
What I normally do to make sure divs are centered is to make the whole page body a flexbox, with a column direction and then align and justify to center. It's the most reliable for me body { display : flex; flex-direction: column; align-items : center ; justify-content: center; }
Marked as helpful0 - @beowulf1958Posted 12 months ago
Great job on the first challenge
A more reliable way to center a component is to use flex on the parent
.main-div { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 100vh; }
Hope this helps.
Marked as helpful0
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