Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodrigolira/f0f75b4ea4f1e0314b95d8817bc32d42 to your computer and use it in GitHub Desktop.
Save rodrigolira/f0f75b4ea4f1e0314b95d8817bc32d42 to your computer and use it in GitHub Desktop.
Flexbox Tutorial from Academind
<div class="parent">
<div class="div1">div1</div>
<div class="div2">w=150px</div>
<div class="div3">h=150px</div>
<div class="div4">w/h=150px</div>
<div class="div5">w=200px</div>
<div class="div6">w=200px</div>
</div>
html {
background-color: #fa923f;
padding: 10px;
}
body {
background-color: yellow;
padding: 10px;
margin: 0;
}
/* Flexbox */
.parent {
background-color: #f073e1;
margin: 10px;
padding: 30px;
height: 500px;
display: flex;
flex-flow: row nowrap; /* flex-direction flex-wrap */
align-items: center; /* defaults to stretch, refers to the cross-axis */
justify-content: center; /* refers to main axis */
/*align-content: center;*/ /* in relation to the cross-axis, when there's multiple lines */
}
.div1 {
background-color: #f800db;
margin: 5px;
}
.div2 {
background-color: #f800db;
margin: 5px;
width: 150px;
font-size: 30px;
/*align-self: flex-start;*/
}
.div3 {
background-color: #f800db;
margin: 5px;
height: 150px;
}
.div4 {
background-color: #f800db;
margin: 5px;
width: 150px;
height: 150px;
}
.div5 {
background-color: #f800db;
margin: 5px;
width: 200px;
flex: 0 1 auto; /* flex-grow flex-shrink flex-basis*/
}
.div6 {
background-color: #f800db;
margin: 5px;
width: 200px;
flex: 0 1 auto;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment