responsive flexbox code example

Example 1: 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%;
    }
}

Example 2: css flex

/* Flex */
.anyclass {
	display:flex;
}
/* row is the Default, if you want to change choose */
.anyclass {
	display:flex;
 	flex-direction: row | row-reverse | column | column-reverse;
}

.anyclass {
  /* Alignment along the main axis */
  justify-content: flex-start | flex-end | center | space-between | space-around | space-evenly | start | end | left | right ... + safe | unsafe;
}

Example 3: flex box in css

<!--basic--flex--layout-->
<html>
	<head>
		<style>
			.parent{
              display:  flex or inline-flex;
              flex-direction: row  or column;
              flex-wrap: wrap or wrap-reverse;
 			}
		</style>
	</head>
	<body>
		<div class="parent">
			<div class="child-1"></div>
			.
			.
			.
		</div>
	</body>
</html>

Example 4: flex property in css

The flex property is a shorthand property for:

flex-grow
flex-shrink
flex-basis

Tags:

Css Example