Tap That JOB 2017
Andrei ANTAL
QUALITANCE
Tap That JOB 2017
Early days
Early days
Table based layouts
Table based layouts
Table based layouts - spacer gif
The "display" property
inline | block | flex | inline-block | inline-flex | inline-table | list-item | run-in | table | table-caption | table-column-group | table-header-group | table-footer-group | table-row-group | table-cell | table-column | table-row | none | initial | inherit
#main {
max-width: 600px;
margin: 0 auto;
}
Centering elements and max-width
Box model
div {
width: 300px;
height: 200px;
padding: 15px;
border: 5px solid gray;
margin: 30px;
box-sizing: content-box;
}
Box model
div {
width: 300px;
height: 200px;
padding: 15px;
border: 5px solid gray;
margin: 30px;
box-sizing: border-box;
}
Positioning
Float
img {
float: right;
margin: 0 0 1em 1em;
}
Clearfix
.clearfix {
overflow: auto;
}
Float layout
nav {
float: left;
width: 200px;
}
section {
margin-left: 200px;
}
nav.clearfix
section
section
Float layout
nav {
float: left;
width: 200px;
}
section {
margin-left: 200px;
}
nav.clearfix
section
section
nav {
float: left;
width: 25%;
}
section {
margin-left: 25%;
}
Inline-block layout
nav
section
section
nav {
display: inline-block;
vertical-align: top;
width: 25%;
}
.column {
display: inline-block;
vertical-align: top;
width: 75%;
}
.column
<div class="container">
<div class="item">Red</div>
<div class="item">Orange</div>
<div class="item">Yellow</div>
<div class="item">Green</div>
<div class="item">Blue</div>
</div>
<div class="container">
<div class="item">Red</div>
<div class="item">Orange</div>
<div class="item">Yellow</div>
<div class="item">Green</div>
<div class="item">Blue</div>
</div>
.container {
display: flex;
}
<div class="container">
<div class="item">Red</div>
<div class="item">Orange</div>
<div class="item">Yellow</div>
<div class="item">Green</div>
<div class="item">Blue</div>
</div>
.container {
display: flex;
flex-direction: column; // row is the default
}
<div class="container">
<div class="item">Red</div>
<div class="item">Orange</div>
<div class="item">Yellow</div>
<div class="item">Green</div>
<div class="item">Blue</div>
</div>
.container {
display: flex;
flex-direction: row-reverse;
}
.item:nth-child(5) {
order: -1;
}
.item:nth-child(2) {
order: 1;
}
.item:nth-child(2) {
order: 1;
}
.item:nth-child(4) {
order: 1;
}
<div class="container">
<div class="item">Red</div>
<div class="item">Orange</div>
<div class="item">Yellow</div>
<div class="item">Green</div>
<div class="item">Blue</div>
</div>
.container {
display: flex;
justify-content: center;
}
<div class="container">
<div class="item">Red</div>
<div class="item">Orange</div>
<div class="item">Yellow</div>
<div class="item">Green</div>
<div class="item">Blue</div>
</div>
.container {
display: flex;
justify-content: space-between;
}
.container {
display: flex;
height: 200px;
/* align-items: stretch; */
}
.container {
display: flex;
height: 200px;
align-items: flex-end;
}
.item:nth-child(3) {
align-self: stretch;
}
.container {
display: flex;
height: 200px;
}
.item {
margin: auto;
}
.container {
display: flex;
}
.item:nth-child(1) {
margin: auto;
}
.item:nth-child(2) {
margin: auto;
}
.container {
display: flex;
justify-content: center;
align-items: center;
}
.container {
display: flex;
}
.item:nth-child(4) {
flex-grow: 1;
}
.container {
display: flex;
}
.item:nth-child(4) {
flex-grow: 1;
}
.item:nth-child(5) {
flex-grow: 2;
}
.container {
display: flex;
}
.item:nth-child(4) {
flex-grow: 1;
}
.item:nth-child(5) {
flex-grow: 2;
}
.container {
display: flex;
}
.item {
flex-shrink: 0;
}
.item:nth-child(7) {
flex-shrink: 1;
}
.container {
display: flex;
}
.item {
flex-basis: 60px;
}
.container {
display: flex;
}
.item {
flex-basis: 60px;
}
.item:nth-child(1) {
flex-grow: 1;
}
.item {
flex-grow: 1;
flex-shrink: 1;
flex-basis: auto;
}
/* equivalent to */
.item {
flex: 1 1 auto;
}
.container {
display: flex;
flex-wrap: wrap;
}
.item {
flex: 1 0 150px;
}
.container {
display: flex;
flex-wrap: wrap;
}
.item {
flex: 1 0 150px;
}