Skip to content

Latest commit

 

History

History
628 lines (515 loc) · 10.8 KB

README.md

File metadata and controls

628 lines (515 loc) · 10.8 KB

Flexbox Playground

Getting Started

  1. Clone the repository: git clone https://github.com/Erikote04/Flexbox-Playground.git

  2. Open the index.html file in a web browser.

  3. Follow the steps down below and become a master in Flexbox

Flexbox Properties

Container

.container {
	flex-direction: row | row-reverse | column | column-reverse; /* direction of the main-axis */
	flex-wrap: nowrap | wrap | wrap-reverse; /* new line? */
	justify-content: flex-start | flex-end | center | space-between | space-around | space-evenly; /* main-axis */
	align-items: stretch | flex-start | flex-end | center | baseline; /* cross-axis */
}

Item

.item {
	align-self: auto | stretch | flex-start | flex-end | center | baseline;
	order: 0 | <integer>;
	flex-grow: 0 | <integer>; /* how much an item can grow */
	flex-shrink: 1 | <integer>; /* how much an item can shrink */
	flex-basis: auto | <length>; /* base width */
}
/* Last 3 properties con be resumed as flex: 0 1 auto */

Roadmap

display: flex

.container {
    display: flex;
}

alt text

flex-direction: row

.container {
    display: flex;
    flex-direction: row;
}

alt text

flex-direction: row-reverse

.container {
    display: flex;
    flex-direction: row-reverse;
}

alt text

flex-direction: column

.container {
    display: flex;
    flex-direction: column;
}

alt text

flex-direction: column-reverse

.container {
    display: flex;
    flex-direction: column-reverse;
}

alt text

justify-content: flex-start

.container {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
}

alt text

justify-content: center

.container {
    display: flex;
    flex-direction: row;
    justify-content: center;
}

alt text

justify-content: space-between

.container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
}

alt text

justify-content: space-around

.container {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
}

alt text

justify-content: space-evenly

.container {
    display: flex;
    flex-direction: row;
    justify-content: space-evenly;
}

alt text

justify-content: flex-end

.container {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
}

alt text

align-items: stretch

.container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: stretch;
}

.i3 {
    height: 200px;
}

alt text

align-items: center

.container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
}

.i3 {
	height: 200px;
}

alt text

align-items: flex-start

.container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
}

.i3 {
	height: 200px;
}

alt text

align-items: flex-end

.container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-end;
}

.i3 {
	height: 200px;
}

alt text

align-items: baseline

.container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: baseline;
}

.i2 {
	height: 200px;
}

.i4 {
	font-size: 70px;
}

alt text

flex-direction: column; justify-content: center; align-items: center;

.container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

alt text

align-self: stretch;

.container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.i2 {
	height: 200px;
}

.i4 {
	align-self: stretch;
}

alt text

align-self: flex-start;

.container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.i2 {
	height: 200px;
}

.i4 {
	align-self: flex-start;
}

alt text

align-self: flex-end;

.container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.i2 {
	height: 200px;
}

.i4 {
	align-self: flex-end;
}

alt text

align-self: center;

.container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.i2 {
	height: 200px;
}

.i4 {
	align-self: center;
}

alt text

align-self: baseline;

.container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.i2 {
	height: 200px;
}

.i4 {
	align-self: baseline;
	font-size: 70px;
}

alt text

order: -1;

.container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.i2 {
	height: 200px;
}

.i4 {
	align-self: center;
	order: -1
}

alt text

order: 1;

.container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.i2 {
	height: 200px;
}

.i3 {
	order: 1;
}

.i4 {
	align-self: center;
	order: -1
}

alt text

flex-grow;

.container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.item {
    flex-grow: 1;
}

alt text

flex-grow;

.container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.item {
    flex-grow: 1;
}

.i3 {
	flex-grow: 2;
}

alt text

flex-grow;

.container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.i5 {
	flex-grow: 1;
}

alt text

flex-basis;

.container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.i3 {
	flex-basis: 40%;
}

alt text

flex-shrink;

.container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.i3 {
	flex-basis: 300px;
	flex-shrink: 1; /* allows the item to shrink */
	/* flex: 0 1 300px */
}

alt text

flex-shrink;

.container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.i3 {
	flex-basis: 300px;
	flex-shrink: 0; /* doesn't allows the item to shrink */
	/* flex: 0 0 300px */
}

alt text

flex-wrap: nowrap

<div class="container">
	<div class="item">1</div>
    <div class="item">2</div>
    <div class="item">3</div>
    <div class="item">4</div>
    <div class="item">5</div>
    <div class="item">6</div>
    <div class="item">7</div>
    <div class="item">8</div>
    <div class="item">9</div>
    <div class="item">10</div>
</div>
.container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
}

alt text

flex-wrap: wrap

.container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

alt text

align-content: flex-start

.container {
	height: 800px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    align-content: flex-start;
}

alt text

align-content: flex-end

.container {
	height: 800px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    align-content: flex-end;
}

alt text

align-content: center

.container {
	height: 800px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    align-content: center;
}

alt text

align-content: space-between

.container {
	height: 800px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    align-content: space-between;
}

alt text

align-content: space-around

.container {
	height: 800px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    align-content: space-around;
}

alt text

align-content: space-evenly

.container {
	height: 800px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    align-content: space-evenly;
}

alt text