Layout / CSS Flexbox / CSS Grid
Page layout is a critical part of website design. CSS offers several options for dealing with page layout.
Updated
CSS Position
- Static (Apprentice): Static is the default position, where elements sit in the normal flow of the page and top and left don't move them.
- Relative (Apprentice): Relative positioning moves an element away from its own normal place, and keeps the space it would have used.
- Absolute (Apprentice): Absolute positioning takes an element out of the page's flow and places it relative to its nearest positioned ancestor, usually a parent with position relative.
- Fixed (Apprentice): Fixed positioning places an element relative to the browser window, so it stays on screen while the page scrolls.
- Sticky (Apprentice): A sticky element scrolls with the page until it reaches its top offset, then stays put until its parent scrolls away.
FlexBox
- FlexBox: an overview (Apprentice): Setting display to flex on an element lines up its children side by side in a row, and flex-direction can turn that row into a column.
- Justify Content (Apprentice): The justify-content property on a flex container decides where the extra space goes, so its items can sit at the start, the end, the center or spread out.
Grid
- Grid (Journeyman): CSS Grid lays a container's children out in rows and columns at once, with column widths you set in fr, % or px, gaps between the cells, and items that can span more than one cell.