CSS Flex box code example

Example 1: space between flexbox

justify-content: space-between;

Example 2: display flex column

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

Example 3: display flex

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

//My youtube:'https://www.youtube.com/HasibulIslambd'

Example 4: css flexbox syntax

Display: flex 
Flex-direction: row | row-reverse | column | column-reverse
align-self: flex-start | flex-end | center | baseline | stretch
justify-content: start |  center | space-between | space-around | space-evenly

Example 5: flexbox in css

/* 
  Most Common Flexbox properties:

    display: flex; 
    flex-direction: row / column;     --> used to justify the direction of content
    flex-wrap: wrap;                  --> holds the content inside flexbox container

  These Properties are also part of flexbox and only apply on a container which contain flexbox property

  Justify content:
    center
    start
    end
    baseline
    space-around -->commonly used

  Align items:
    center  
    baseline
    
  fr = fill up any available space

*/

.flexbox {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-around;
    /* column-count: 2;
  columns: 2; */
}

Example 6: flexbox grid

.container {
    max-width: 1335px;
    margin: 0 auto;
}
.grid-row {
    display: flex;
    flex-flow: row wrap;
    justify-content: flex-start;
}
.grid-item {
    height: 550px; /*optional*/
    flex-basis: 20%; /* initial percantage */
    -ms-flex: auto;
    width: 259px; /*optional*/
    position: relative;
    padding: 10px; /*optional*/
    box-sizing: border-box;
}
@media(max-width: 1333px) {/*xl*/
	.grid-item {
    	flex-basis: 33.33%;
    }
}
@media(max-width: 1073px) {/*lg*/
    .grid-item {
    	flex-basis: 33.33%;
    }
}
@media(max-width: 815px) {/*md*/
	.grid-item {
    	flex-basis: 50%;
    }
}
@media(max-width: 555px) {/*sm*/
	.grid-item {
    	flex-basis: 100%;
    }
}

Tags:

Css Example