CSS

Let's finally learn this motherfucker. Perhaps my notes will be of use to you.

Forming opinions (take with a salt mine). Define "useless" to mean "I can more easily do this with script logic"

CSS is fucked up

My trauma dumpster.

Layout

Flexbox

If you can understand the following and answer all the questions, I think you will fundamentally understand flexbox.

Assume English (LTR) text direction for explanation.
Items are ordered along the direction of the main axis, which moves from flex-start to flex-end. The default order priority of all items is 0, which can be changed per-item with order: n.
When items can't fit on one line and wrap, lines (aka contents) are the rows (or columns) of items. The line direction is the same as the main-axis.

  1. flex-direction. Sets main axis direction relative to text direction. row is left-to-right.
  2. flex-wrap. Should we wrap content into multiple lines? If yes, are the lines ordered from top-to-bottom (wrap) or bottom-to-top (wrap-reverse)? If no, align-content doesn't make sense, because there is only one line in the flexbox.
    • Test your understanding: with flex-flow: row wrap-reverse, you can think of the lines as items in a flexbox with flex-direction: column-reverse.
  3. justify-content. How do we position items within a line? We can define relative to main-axis (eg flex-start) or how to space items (eg space-between).
    • Test your understanding: what values make sense for justify-content? There are six.
  4. align-items. Within a line, should items take up all the cross-axis space (stretch), or if not, how should we position items along the line's cross-axis?
    • Test your understanding: what values make sense for align-items? There are 3 other than stretch and baseline (using text baseline inside items).
  5. align-content. If we have lines (aka flex-wrap is not nowrap), should lines take up all space (stretch)? If not, how should we position the lines?
    • Test your understanding: what values make sense for align-content? Hint: if you ignore stretch, the other values are the same as another flex property.
    • Test your understanding: with flex-flow: wrap, if the lines were items, what would the flex-direction of this flex-box be? What would it be with flex-flow: wrap-reverse?

Grid

Grids

Items

Basics

Selectors

Specificity. Combinators don't change weight

id
> .class :pseudo-selector [attr-selector*='value']
> type-selector p ::pseudo-element p::first-letter

Box model

%% All elements, default %%
* + * {
	margin: 1em; 
}

%% Reduce the spacing for your menu %%
.menu * + * {
	margin: 0.75em;
}

Positioning

Colour. Use hsl for ease of computing the arguments for colours that will give visual harmony.

Media queries