CSS Flexbox: justify-content

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 👋 By default, flex is stretching the height of the items based on the highest item. But when we need to, we can control the vertical position (cross axis) of the items with align-items. Controlling The Vertical Position of...
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 👋
We've learned in the previous post that applying display: flex to a flex container by default will turn flex items into columns.
And when the total width of flex items is bigger than the container, they will stretch to fit the horizontal axis of the flex container.
There could be a case where we have extra space when the flex container's width is bigger than the total width of the flex items as below:
How to give space to the columns so the layout would fall nicely into places?
There is a property that controls the space on the main axis (horizontal position) of a flex container.
That property is justify-content.
📝 Note:
We always put flex properties in the same place where we assign display: flex.
justify-content What it does is it takes the extra space, divides it, and put them between the columns.
⭐ This value is commonly used to space out columns.

It does the same as space-between, but the difference is that it puts the extra space around a column.
I draw partitions so you can see the spaces on the left and the right of each column.
Visually space-evenly makes the layout look balance because it divides and puts the extra space evenly.
This is the default value of justify-content.
It makes the columns positioned to the left (start) of the flex container.

As the name stated, it is positioned the columns to the center of the flex container.

It is positioned the columns to the right (end) of the flex container.

justify-content property works with main axis (horizontal position) and is used to space out columns in a flex container.