display: flex;
in CSSAssume you have an HTML file that has the following structure:
<header>Sample flexbox example</header>
<section>
<article>First article</article>
<article>Second article</article>
<article>Third article</article>
</section>
We now select the elements that we want displayed as flexible boxes
<artilce>
elements to display as flexboxes, creating 3x equal sized boxes evenly distributed within the parent element <section>
section {
display: flex;
}
This property can be changed with flex-direction
flex-direction: column;
flex-wap: wrap;
flex: unitOfMeasure;
flex-direction: row;
flex-wrap: warp;
/*becomes*/
flex-flow: row warp;
flex
propertyflex
is a unitless value that dictates how much space an element will take up along the main axis relative to other elements in the spaceflex: 1
will each take 1/3rd of space availableflex: 2
, that element would appear twice as large as the other elements (see below: Third article)flex
can specify flex-grow
, flex-shrink
, and flex-basis
div {
display: flex;
align-items: center;
justify-content: space-around;
}