Flexbox and CSS Grid
.container {
background: green;
height: 20rem;
}
rule set
selector
property
value
or "flex"
.flex-container {
display: flex;
}
flex
flex-grow
flex-shrink
flex-basis
flex-direction
justify-content
align-items
order
flex-wrap
flex-flow
justify-items
align-content
The flex properties are:
display: flex;
flex: 1;
align-items: center;
justify-content: center;
flex-direction: row | column
@media screen and (max-width: 1024px)
or "grid"
.grid-container {
display: grid;
}
Grid properties are:
grid-template-columns
grid-gap
justify-content
align-content
grid-area
grid-template-areas
grid-template-rows
grid-column-start
grid-column-end
display: grid
grid-gap
grid-template-columns: 1fr 2fr;
justify-content: center;
align-content: center;
grid-template-areas: 'myArea myArea'
grid-area: myArea
Flex:
CSS Grid:
Codepens used in this presentation: