bbTeX 22/04/21 - Sylvain Pollet-Villard
* special mention to PostCSS and cssnext that are doing this right
Let's give CSS a second chance !
They used to,
but it's much better today !
(except for the old hopeless ones)
A good read: smashingmagazine.com/2019/02/css-browser-support/
Your problem is not as simple as you think.
i.e. center a div horizontally and vertically:
- based on what reference should it be centered ?
- how is the total height calculated ?
- what if viewport width is not enough to contain the div ?
- what happens when text or blocks are added next to the div ?
Placing a single element does not answer the question
of how the content is distributed.
|Absolute||px, cm, mm, in||Print, lines and pixelled media|
|Relative to Font||em, rem, ch, lh||Text-related dimensions|
|Relative to viewport||vh, vw, vmin, vmax||Screen layouts|
|Relative to container||%, fr||Container layouts|
Well, I don't know how to tell you this, but...
Trying random stuff and pray that it works
does not make you a good developer.
Having an immediate visual feedback on debugging is great, but not an excuse for laziness.
Read about every CSS property you use. The more you know, the less errors you will make.
Yes it is,
If you're designing your website for dynamic content on a wide range of screens, you know very little about both the content and the container
In these conditions, layout and positioning is hard.
But it's doable, with the proper tools.
although this never happens
unless you tell it to do so
CSS has been invented to style documents and pages,
back in the days where we call webapps like that
At that time, the goal was to have a good looking,
consistent styling for as few bytes as possible.
You should definitely learn CSS Flex and Grid
a.k.a. i don't know what I'm doing with my selectors
It's not a bug,
it's a feature !
Stylesheets are global by design, because they aim for consistency.
Structure and organization rely on two main principles: cascade and specificity
Graphic charter, visual specs, design system...
all is about consistency
Organize your selectors
Specificity is not something you have to fight for,
but something you have to think about
Tip: layout-related styles usually need a higher specificity than other styles
maybe I'm part of the problem,
but you still bore me
Let's finish with some CSS
your face after you've been
sold CSS as a good language