flexbox examples

Example 1: css flexbox image

/********** What to do in case of <div> containing images?  ***********

In this case, the "flex" property is no longer effective in regulating 
the size of the items (<div>) inside the container. This happens because 
the size of the image itself will impact the <div>. So, to force the 
image to fit the desired size, we need to do the following: */

.big_container {
  display: flex;
  flex-wrap: wrap;    
}

div {
  flex: 1;       
}

img {
  width: 100%;        /* Make it occupy 100% of the size of the <div> */
  min-width: 280px;   /* Give it a minimum size so that it will wrap 
                         instead of just shrinking */
}

Example 2: flex css end

.item {
  align-self:flex-start | flex-end | center | baseline | stretch;
}

Example 3: 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 4: 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 5: flexbox css

.container {
  align-content: flex-start | flex-end | center | space-between | space-around | space-evenly | stretch | start | end | baseline | first baseline | last baseline + ... safe | unsafe;
}

Example 6: css flexbox layout examples

<div class="container">
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  ...
</div>