diff options
author | Jasper Ras <jras@hostnet.nl> | 2025-01-13 18:04:20 +0100 |
---|---|---|
committer | Jasper Ras <jras@hostnet.nl> | 2025-01-13 18:04:20 +0100 |
commit | 969b96c2531fb986f6c7f21fd544391b439defd7 (patch) | |
tree | 1352f35e140759622ecc1c7aca6234c3ed93ef5f /3 resources/CSS.md | |
parent | 9232b8d817d4cd4122947375156fa2fa1e9fba14 (diff) |
vault backup: 2025-01-13 18:04:20
Diffstat (limited to '3 resources/CSS.md')
-rw-r--r-- | 3 resources/CSS.md | 28 |
1 files changed, 28 insertions, 0 deletions
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 |