CSS Flexbox: flex-direction

Ayu is a tech blogger, open source contributor & maintainer, and tech community enthusiast based in the Netherlands. She loves photography and iced coffee!
Search for a command to run...

Ayu is a tech blogger, open source contributor & maintainer, and tech community enthusiast based in the Netherlands. She loves photography and iced coffee!
No comments yet. Be the first to comment.
This series is my log of what I learned about responsiveness in CSS
Hello Fellow Codenewbies 👋 We've learned about Flexbox, justify-content, align-items, flex-direction and media queries. In this post, we will create a simple navbar with what we've learned so far. We will work on the bigger screen and working our ...
Hi friends 👋, I've been writing tech blog posts for a few years now. If you don't know me yet, English is my second language. My mother tongue is Indonesian, and I'm also surrounded by Dutch every da

I frequently receive messages from enthusiastic contributors who have completed 2 or 3 high-quality pull requests (PRs) in just 1 month. They’re proactive, their work is top-tier, and they’ve handled

A few months ago, I shared a story about building an automated open source portfolio using just my smartphone and an AI assistant while on vacation. My main goal was to stop the "spreadsheet struggle"

Recently, I read Bekah Hawrot Weigel’s blog post, "When 'Local' Went Global: The Pandemic Era of International Communities." As someone active in many online communities, I found it a bit sad, but I agree with her points and think they apply to open ...

Hacktoberfest is almost over. How has your contribution journey been so far? Are you confident about contributing to open source projects, or are you still struggling to find your way? If you're new to open source and still feel overwhelmed, that's c...

Hello Fellow Codenewbies 👋
Flexbox is known as one dimension.
It means that it deals with one dimension layout at a time, the column or the row.
When we talk about a column or a row in flexbox, we are talking about the main axis or the cross axis.

flex-directionBefore we talk about the values of flex-direction, you can check the playground that I provide below.
The screenshots that I attached in each value's explanation are based on this playground.
flex-direction: ⭐ This the default value.
This value makes the flex container becoming a row and the flex items become columns.

Same as row, but it reverses the order of the flex items.

This value makes flex container becomes column and flex items become rows.
In a glimpse, it looks like the default layout when we don't apply display: flex.
But under the hood, this value switches the main axis.
And because there is a change on the main axis, there are changes as well in the behavior of:
justify-content
align-items

Same as column, but it reverses the order of the flex items.

We usually use media queries when we want to apply flex-direction.
flex-direction is changing the main axis around.flex-direction: