From 9642cd7ae24f0ba79ce5647c709b35ae8f06a285 Mon Sep 17 00:00:00 2001 From: Jasper Ras Date: Sun, 19 Jan 2025 21:14:51 +0100 Subject: vault backup: 2025-01-19 21:14:51 --- 3 Resources/CSS.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 3 Resources/CSS.md (limited to '3 Resources/CSS.md') diff --git a/3 Resources/CSS.md b/3 Resources/CSS.md new file mode 100644 index 0000000..32a3113 --- /dev/null +++ b/3 Resources/CSS.md @@ -0,0 +1,28 @@ +**Display** +display none vs visibility hidden: display: none is really like the element does not exist. Visibility hidden just hides it but it still takes space. + +A display: none element can still have size and be coloured with a background image. It still doesn't take space. This can be used for a timeline bar for example! + +**Flexbox** +Flexbox deals with layout always in only one dimension; it's possible to specify which dimension: either vertical or horizontal. + +Two axes: main and cross + +Control main axis: `flex-direction: row|row-reverse|column|column-reverse`. The first two make it a horizontal layout and the latter make it a vertical layout. + +Cross axis is always the opposite of `flex-direction`, so if `flex-direction: row-reverse` the cross axis is `column-reverse`. + +The writing mode determines where the start and end are, based on for example languages. Japanese is written from right-to-left rather than western left-to-right. +So while in Europe the start of a flexbox is at the left and the end at the right in Japan this would be reversed. + +**Relationships** +An important aspect of creating layouts with CSS is the relationships of elements with each other. For example parent/child relationships. + +If we change the width of a parent element; the height of all children increase. This happens because the total area of the parent remains the same. + +When the edge of a child aligns with its parent and we add a margin to the child; it pushes to the parent as well. This phenomenon is called ==collapsing margins==. It can be prevented by unaligning the edge(s) for example by adding padding or setting `display: flow-root;`. + +In `flexbox` siblings push against each other; if we add padding to one, it pushes against the other making it smaller. This does not happen in grid, where each cell gets a fixed size and the padding pushes against its own side. + +**Centering stuff** +Use `margin-inline: auto;` -> this adds margins on both sides of the element. This can be used to center stuff on the page for example. \ No newline at end of file -- cgit v1.2.3