flexbox 101 code example

Example 1: flex css end

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

Example 2: how to create seprate flex box for adding items into the box

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

.item {
  width: 32%;
  padding-bottom: 32%; /* Same as width, sets height */
  margin-bottom: 2%; /* (100-32*3)/2 */
  position: relative;
}

Example 3: whats the best ways to 3 x 3 perfects squares on a webpage using flexbox

.parent {
  display: flex;
  height: 300px; /* Or whatever */
}

.child {
  width: 100px;  /* Or whatever */
  height: 100px; /* Or whatever */
  margin: auto;  /* Magic! */
}

Tags:

Css Example