DEV Community

Cover image for #css, #webdev, #beginners, #codenewbie
Ali Hamza
Ali Hamza

Posted on

#css, #webdev, #beginners, #codenewbie

Hello Dev Community! πŸ‘‹

It is officially Day 6 of my web development journey! Yesterday, I learned how to create space using the Box Model. Today, I stepped into the absolute game-changer of frontend layouts: CSS Flexbox.

Before today, aligning elements horizontally or centering a button vertically felt like guesswork. Today, I learned how to control my layout vectors with just a few lines of code.


🧠 Key Learnings From Day 6

Flexbox is all about a parent container (the Flex Container) controlling its children (Flex Items) along a main axis and a cross axis.

Here are the structural properties I mastered today:

1. Activating the Layout

By simply applying display: flex; to a parent container, all its direct children instantly align horizontally (row layout) by default. No more messy floats!

2. Controlling Alignment

  • justify-content: Controls spacing along the main axis. I experimented with center, space-between (perfect for navbars), and space-around.
  • align-items: Controls spacing along the cross axis. Setting this to center makes vertical alignment effortless.
  • flex-direction: Allows switching the axis from a row layout to a vertical stack (column), which is crucial for mobile-responsive design.

πŸ› οΈ What I Actually Built / Refactored

I took my navigation bar and the "About Me" form from the previous days and completely rebuilt their positioning using Flexbox:

  • The Navbar: Wrapped my logo and nav links in a header container, applied display: flex; and justify-content: space-between;. Now the logo sits on the far left and the links sit perfectly on the far right, completely responsive.
  • The Centered Button: I finally learned how to perfectly center my submission button inside the form box using justify-content: center;.

The code looks incredibly clean, and I don't have to use random margins or line breaks (<br>) to push things around anymore!


🎯 My Goal for Tomorrow (Day 7)

Now that I can create clean structural layouts, it is time to make them look professional on mobile screens:

  • Learning Media Queries and Responsive Web Design.
  • Understanding how to change layouts smoothly based on different screen sizes.

πŸ’¬ Let's Connect!

To the senior devs: What is the one Flexbox shorthand property you use the most? To beginners: Have you cracked the ultimate challenge yetβ€”centering a <div>?

My Flexbox-powered responsive structures are pushed to GitHub!
[Links in the Comments]

Keep building! πŸš€

Top comments (0)