Flexbox Guild

In this example below you will see how to do a Flexbox Guild with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by jccheng, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright jccheng ©

Technologies

  • HTML
  • CSS
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>Flexbox Guild</title>
  
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">

  
      <style>
      /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */
      @import url(https://fonts.googleapis.com/css?family=Open+Sans);
body {
  font-family: 'Open Sans', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.flex-container {
  padding: 0;
  margin: 0;
  height: 500px;
  list-style: none;
  display: flex;
  flex-flow: row wrap;
  justify-content: space-around;
  align-items: center;
  align-content: center;
}

.item {
  background: blue;
  padding: 5px;
  width: 200px;
  height: 150px;
  margin-top: 10px;
  border: 2px solid #55ffff;
  line-height: 150px;
  color: white;
  font-weight: bold;
  font-size: 3em;
  text-align: center;
}

.item:nth-of-type(2) {
  order: 2;
}

.item:nth-of-type(1) {
  order: 3;
  flex: 2 1 auto;
  align-self: flex-end;
}

.parent {
  display: flex;
  /* Gold! */
  height: 500px;
  border: 1px solid #000;
  margin: 20px;
}

.child {
  padding: 20px;
  margin: auto;
  /* Gold! */
  color: white;
  background: green;
  border-radius: 10px;
  font-size: 20px;
}

    </style>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>

</head>

<body>

  <ul class="flex-container">
  <li class="item">1</li>
  <li class="item">2</li>
  <li class="item">3</li>
  <li class="item">4</li>
  <li class="item">5</li>
  <li class="item">6</li>
</ul>

<div class="parent">
  <h1 class="child">center me!</h1>
</div>
  <script src='https://code.jquery.com/jquery-2.2.4.min.js'></script>

  

</body>

</html>

/*Downloaded from https://www.codeseek.co/jccheng/flexbox-guild-wWWrPX */
@import url(https://fonts.googleapis.com/css?family=Open+Sans);
body {
  font-family: 'Open Sans', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.flex-container {
  padding: 0;
  margin: 0;
  height: 500px;
  list-style: none;
  display: flex;
  flex-flow: row wrap;
  justify-content: space-around;
  align-items: center;
  align-content: center;
}

.item {
  background: blue;
  padding: 5px;
  width: 200px;
  height: 150px;
  margin-top: 10px;
  border: 2px solid #55ffff;
  line-height: 150px;
  color: white;
  font-weight: bold;
  font-size: 3em;
  text-align: center;
}

.item:nth-of-type(2) {
  order: 2;
}

.item:nth-of-type(1) {
  order: 3;
  flex: 2 1 auto;
  align-self: flex-end;
}

.parent {
  display: flex;
  /* Gold! */
  height: 500px;
  border: 1px solid #000;
  margin: 20px;
}

.child {
  padding: 20px;
  margin: auto;
  /* Gold! */
  color: white;
  background: green;
  border-radius: 10px;
  font-size: 20px;
}

Comments