Skip to content

sarn1/example-flexbox

Repository files navigation

example-flexbox

Examples using Flexbox

https://webdesign.tutsplus.com/courses/css-flexbox-essentials

Sample Website https://codepen.io/sarn1/pen/yPWKNr

Thai Flag https://codepen.io/sarn1/pen/GOadma

Notes

site01 https://codepen.io/sarn1/pen/ZaNyxb

.container {
    background-color: #555;
    width: 800px;
    height: 400px;
    margin: 0 auto;
}

.item { }

.item1 { background-color: red; }
.item2 { background-color: blue; }
.item3 { background-color: green; }
.item4 { background-color: orange; }

alt text

.container {
    background-color: #555;
    width: 800px;
    height: 400px;
    margin: 0 auto;
    display: flex; /* look */
}

.item { }

.item1 { background-color: red; }
.item2 { background-color: blue; }
.item3 { background-color: green; }
.item4 { background-color: orange; }

alt text

.container {
    background-color: #555;
    width: 800px;
    height: 400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.item {
    flex-basis: 150px; /* default, like width: 150px */
    flex-grow: 1; /* grows to relative to the rest of the item, thus fills parent */
}

/* shorthand of the above lines 
.item { flex: 1 1 150px; }
 */

.item1 { background-color: red; }
.item2 { background-color: blue; }
.item3 { background-color: green; }
.item4 { background-color: orange; }

alt text

site02 https://codepen.io/sarn1/pen/pdmwVo

  • flex

alt text

site03 https://codepen.io/sarn1/pen/OOYgwr

  • flex-direction

alt text

site04 https://codepen.io/sarn1/pen/QORgJL

  • order

alt text

site05 https://codepen.io/sarn1/pen/pdmrzg

  • flex-wrap alt text

alt text

site06 https://codepen.io/sarn1/pen/xPNpRY

  • flex-flow
  • flex-content
    • center - centers the items
    • space-around - centers the items but have spacing on the ends
    • space-between - centers the items but not spacing on the ends
    • flex-start - flush right
    • flex-end - flush to the right alt text alt text alt text alt text

site07 https://codepen.io/sarn1/pen/mqYpvd

  • Same as site06 but by row. alt text

site08 https://codepen.io/sarn1/pen/aVrEeQ

  • align-content which is similar to justify-content and it deals with column and rows. alt text

site09 https://codepen.io/sarn1/pen/BmeYwZ

  • align-items alt text alt text alt text alt text

site10 https://codepen.io/sarn1/pen/WXBMmy

  • align-self alt text

About

Example sites using CSS Flexbox.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published