Flexbox

  1. What is Flexbox?
    1. Flex Containers & Flex Items
    2. The Axes

What is Flexbox?

The Flexible Box Model is a one dimensional layout model that provides a method to offer space distribution and powerful alignment capabilities.

Flex Containers & Flex Items

The flex container is the element that holds flex items. Flex items are direct children of flex containers.

A container is created with display: flex;

<div class="flex-container">
	<div>Flex Item 1</div>
	<div>Flex Item 2</div>
	<img src="pic.jpg" alt="Also a flex item" />
</div>	
Flex Container PropertiesFlex Item Properties
flex-directionorder
flex-wrapflex-grow
flex-flowflex-shrink
justtify-contentflex-basis
align-itemsalign-self
align-content 

The Axes

There are two axes to keep in mind when using flexbox: the main axis, and the cross axis.

The main axis is always along the direction of the flex-direction, and the cross-axis is always perpendicular to it. flex-direction is either row or column.


© 2024. knznsmn. All rights reserved.