@atefkhaled7
Posted
Great job on completing your first project on Frontend Mentor! Itโs an exciting milestone, and I appreciate your effort. ๐
Now, letโs address the issue you faced with centering a <div>. Centering elements can be tricky, especially when youโre just starting out. Here are some suggestions to improve your code:
Centering Elements:
- Consider using Flexbox or Grid for more consistent results.
- For horizontal centering, use justify-content: center; (Flexbox) or place-items: center; (Grid).
- For vertical centering, use align-items: center; (Flexbox) or place-items: center; (Grid).
CSS Reset: Consider using a CSS reset to remove default browser styles. This ensures a consistent starting point for your styling. EX: *{ margin: 0; padding: 0; box-sizing: border-box; }
You should add it first thing in the CSS file using the universal selector *{ } OR add it to the body { }
Remember, practice makes perfect! Keep experimenting, learning, and building more projects. Happy coding! ๐
Marked as helpful
@meher-hex
Posted
@atefkhaled7 Thank you so much for your feedback! I've already used CSS Flexbox and added exactly what you suggested. Unfortunately, it never works for me or any other typical solutions. However, this is my first time hearing about CSS reset. Thank you for enlightening me on that. I'll make sure to use it on my next project.