Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML Introduction to HTML and CSS (2016) Make It Beautiful With CSS Select and Style Multiple Elements by Class

What is the display:flex and justify-content: space-around used for?

What is the display:flex and justify-content: space-around used for? Unfortunately it is not explained in video lectures. Thanks.

1 Answer

Matthew Long
Matthew Long
28,407 Points

Flex is a pretty large css concept to explain on here. You'd be better off taking a look at the guide to flexbox on css-tricks.

There is also a course solely on flex here on Treehouse.

Basically, flex is a css property that is used for layouts and positioning. The main idea behind the flex layout is to give the container the ability to alter its items' width/height (and order) to best fill the available space (mostly to accommodate to all kind of display devices and screen sizes).

The justify-content: space-around; property is where items are evenly distributed in the line with equal space around them. Note that visually the spaces aren't equal, since all the items have equal space on both sides. The first item will have one unit of space against the container edge, but two units of space between the next item because that next item has its own spacing that applies.