Skip to content

Commit 4213d75

Browse files
committed
[css-color-5] Improve swatches
1 parent a248b72 commit 4213d75

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

css-color-5/Overview.bs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ spec:css-color-4; type:dfn; text:gamut
2121
</pre>
2222

2323
<style>
24-
.swatch {display: inline-block; height: 1.2em; width: 1.2em;}
25-
.peru {background-color: peru;}
26-
.darkperu {background-color: rgb(57.58%, 32.47%, 3.82%);}
24+
.swatch {
25+
display: inline-block;
26+
vertical-align: calc(-.1em - 3px);
27+
padding: .6em;
28+
background-color: var(--color);
29+
border: 3px solid white;
30+
border-radius: 3px;
31+
box-shadow: 1px 1px 1px rgba(0,0,0,.15)
32+
}
2733
</style>
2834

2935
Introduction {#intro}
@@ -223,10 +229,10 @@ Adjusting colors: the ''color-adjust'' function {#coloradjust}
223229
<pre class="lang-css">adjust-color(peru, lightness(-20%));</pre>
224230

225231
The calculation is as follows:
226-
* peru (#CD853F) <span class="swatch peru"> </span> is lch(62.2532% 54.0114 63.6769)
232+
* <span class="swatch" style="--color: peru"></span> peru (#CD853F) is lch(62.2532% 54.0114 63.6769)
227233
* adjusted lightness is 62.2532% - 20% = 42.2532%
228234
* adjusted result is lch(42.2532% 54.0114 63.6769)
229-
* which is rgb(57.58%, 32.47%, 3.82%) <span class="swatch darkperu"> </span>
235+
* which is <span class="swatch" style="--color: rgb(57.58%, 32.47%, 3.82%)"></span> rgb(57.58%, 32.47%, 3.82%)
230236
</div>
231237

232238
<img src="images/adjust_red_lightness30.png" alt="Result of adjust-color(red, lightness(30%)" />

0 commit comments

Comments
 (0)