Notes
-
@layer alayer, blayer, zlayer;
-
Declarations for
border
, color
and
background-color
declared in alayer
and
blayer
are not applied
('outside wins')
HTML
<div class="mycontainer">
<div class="content_one">
<p>Hello world</p>
</div>
</div>
CSS
@layer alayer, blayer, zlayer;
@layer alayer {
div.content_one {
background-color: black;
color: white;
border: 2em solid red;
}
}
@layer blayer {
div.content_one {
background-color: blue;
color: magenta;
border: 1em solid green;
}
}
@layer zlayer {
div.content_one {
height: 10vh;
display: flex;
padding: 0 3em;
margin: auto;
}
}
div.content_one {
background-color: yellow;
border: 1em solid orange;
color: cyan;
}
Notes
-
@layer alayer, blayer, zlayer;
-
Rules defined in
blayer
have higher priority than those defined
in
alayer
HTML
<div class="mycontainer">
<div class="content_two">
<p>Hello world</p>
</div>
</div>
CSS
@layer alayer, blayer, zlayer;
@layer alayer {
div.content_two {
background-color: black;
color: white;
border: 2em solid red;
}
}
@layer blayer {
div.content_two {
background-color: blue;
color: magenta;
border: 1em solid green;
}
}
@layer zlayer {
div.content_two {
height: 10vh;
display: flex;
padding: 0 3em;
margin: auto;
}
}
Notes
-
@layer alayer, blayer, zlayer;
-
Properties declared from within the
'outside'
code block have
revert-layer
as value
-
Matching declarartions in the CSS layer with the highest priority are used
-
revert-layer
results in matching declarations in the next
highest priority CSS layer being used
-
Thus rules from
blayer
are applied
HTML
<div class="mycontainer">
<div class="content_three">
<p>Hello world</p>
</div>
</div>
CSS
@layer alayer, blayer, zlayer;
@layer alayer {
div.content_three {
background-color: black;
color: white;
border: 2em solid red;
}
}
@layer blayer {
div.content_three {
background-color: blue;
color: magenta;
border: 1em solid green;
}
}
@layer zlayer {
div.content_three {
height: 10vh;
display: flex;
padding: 0 3em;
margin: auto;
}
}
div.content_three {
background-color: revert-layer;
border: revert-layer;
color: revert-layer;
}
Notes
-
@layer alayer, blayer, zlayer;
-
Declarations for
color
, background-color
and
border
in both 'outside'
and blayer
blocks have the revert-layer
value
-
Thus the declarations for these properties in
alayer
are used
HTML
<div class="content_four">
<p>Hello world</p>
</div>
CSS
@layer alayer, blayer, zlayer;
@layer alayer {
div.content_four {
background-color: black;
color: white;
border: 1em solid red;
}
}
@layer blayer {
div.content_four {
background-color: revert-layer;
color: revert-layer;
border: revert-layer;
}
}
@layer zlayer {
div.content_four {
height: 10vh;
display: flex;
padding: 0 3em;
margin: auto;
}
}
div.content_four {
background-color: revert-layer;
border: revert-layer;
color: revert-layer;
}