Layout
padding vs margin
https://www.youtube.com/watch?v=EhbZGV2dqZ4
margin
https://www.youtube.com/watch?v=Azfj1efPAH0
Centering
Grid
horizontally, justify-*
justify-content
justify-self
vertically, align-*
align-* works differently in flex and grid
align-content
align-self
These only work within flex boxes.
.container {
display: flex;
margin-left: auto;
margin-right: auto;
}
right justify
.container {
display: flex;
margin-left: auto;
}
Grid
Grid Container
The element on which display: grid
is applied.
I’ve picked body.
body {
display: grid;
grid-template-columns: 1fr 4fr;
}
Grid Items
The children (i.e. direct descendants) of the grid container.
Mine are header
, section
, article
and footer
.
header {
display: block;
grid-row: 1;
grid-column: 1 / span 2;
}
section {
display: block;
grid-row: 2;
grid-column: 1;
}
article {
display: block;
grid-row: 2;
grid-column: 2;
}
footer {
display: block;
grid-row: 3;
grid-column: 1 / span 2;
}
Positioning items against lines