Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Démystifions les CSS Custom Properties
Search
Audrey Garreau
June 13, 2018
Programming
53
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Démystifions les CSS Custom Properties
Audrey Garreau
June 13, 2018
More Decks by Audrey Garreau
See All by Audrey Garreau
Donner du sens à vos pages web avec Schema.org
agarreau
0
340
Other Decks in Programming
See All in Programming
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
エージェンティックRAGにAWSで入門しよう!
har1101
9
1.9k
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.6k
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
7
1.7k
LaravelLive Japan の裏方のすべて — 第188回 PHP勉強会@東京 (2026-06-24)
suguruooki
2
140
SREは、MCPとSRE Agentをこう使え!
kazumax55
0
130
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.9k
自作OSでスライド発表する
uyuki234
1
3.6k
Observability in Practice:Grafana 與 Edge Device SRE 的那些事
blueswen
0
180
dRuby over BLE
makicamel
2
400
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
150
任せる範囲はこう広がった / How the Scope of AI Delegation Has Expanded
nrslib
1
220
Featured
See All Featured
For a Future-Friendly Web
brad_frost
183
10k
The Curse of the Amulet
leimatthew05
2
13k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
410
How to Ace a Technical Interview
jacobian
281
24k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
230
Making the Leap to Tech Lead
cromwellryan
135
9.9k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
Writing Fast Ruby
sferik
630
63k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.4k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.4k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
Transcript
Démystifions les CSS Custom properties
CSS Variables Non, on dit CSS Custom Properties ! 1
Déclaration // Déclaration * { --myvar : #FFF; } //
Utilisation body { background : var(--myvar); }
Déclaration // Déclaration * { --myvar : #FFF; } //
Utilisation body { background : var(--myvar); }
Demo Time ! Attention, vous allez en avoir plein le
css ! https://bit.ly/2LCyfK8
Compatibilité des navigateurs Custom Properties 49 31 16 9.1 @Support
28 22 13 9 Polyfill IE 11 : ShadyCSS
Gestion avec @Support body { background : red; } @support(--color)
{ :root { --color : #FFF; } body { background : var(--color, red); } }
Gestion avec @Support body { background : red; } @support(--color)
{ :root { --color : #FFF; } body { background : var(--color, red); } }
Limites Et oui, on peut pas tout faire avec... 2
Demo Time ! C’est aussi par ce qu’on aime le
risque https://bit.ly/2kWlIWy
Les utilisations avancées = Et vos pages sont plus réactives
3
Demo Time ! Une démo qui ne plante pas n’est
pas une vrai démo ! https://bit.ly/2Jrg3X6
Et ensuite C’est quoi la suite ? 4
Le problème de surchage <my-component> #shadow-root <!-- Overridable part--> <div>
<span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
Le problème de surchage // Style my-component :root { --a-color
: orange; } span { color : var(--a-color); } <my-component> #shadow-root <!-- Overridable part--> <div> <span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
Le problème de surchage // index.css my-component span:hover { --a-color
: red } <my-component> #shadow-root <!-- Overridable part--> <div> <span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
Le problème de surchage // Style my-component :root { --a-color
: orange; } span { color : var(--a-color); } :root span:hover { color : var(--a-color-hover); //red } <my-component> #shadow-root <!-- Overridable part--> <div> <span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
Le problème de surchage // index.css my-component{ --a-color-hover : red
} <my-component> #shadow-root <!-- Overridable part--> <div> <span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
Le problème de surchage // index.css my-component:focus span:hover { --a-color
: blue } <my-component> #shadow-root <!-- Overridable part--> <div> <span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
Le problème de surchage // Style my-component :root { --a-color
: orange;} span { color : var(--a-color); } :root:hover span { color : var(--a-color-hover); } :root:focus span:hover { color : var(--a-color-hover-focus); //blue } <my-component> #shadow-root <!-- Overridable part--> <div> <span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
Le problème de surchage // index.css my-component{ --a-color-hover : red;
--a-color-hover-focus : blue; } <my-component> #shadow-root <!-- Overridable part--> <div> <span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
::part & ::theme la relève <my-component> #shadow-root <!-- Overridable part-->
<div> <span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
::part & ::theme la relève <my-component> #shadow-root <!-- Overridable part-->
<div part=”part-name”> <span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
::part & ::theme la relève <my-component> #shadow-root <!-- Overridable part-->
<div part=”part-name”> <span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
::part & ::theme la relève // index.css my-component::part(part-name) { --my-color:
blue; } my-component::part(part-name):hover { --my-color: red; font-style: italic; } Override Me Don’t Override Me Override Me Don’t Override Me
Custom Type le problème // main.css body { --my-color: orange;
--my-color: url("https://web2day.co/logo.svg"); color: var(--my-color); }
Custom Type pour typer // main.js CSS.registerProperty({ name: "--my-color", syntax:
"<color>", initialValue: "black" });
Merci ! Des questions ? Audrey Garreau CEO Yumigo -
@garreau_audrey - @yumigoteam Jean-François Garreau CTO Sfeir Nantes / GDE Web Technology - @jefbinomed