<div class="wrapper">
<div class="widget red">
<div>R</div>
<div class="bar">
<div class="indicator"></div>
</div>
<div class="value"></div>
</div>
<div class="widget green">
<div>G</div>
<div class="bar">
<div class="indicator"></div>
</div>
<div class="value"></div>
</div>
<div class="widget blue">
<div>B</div>
<div class="bar">
<div class="indicator"></div>
</div>
<div class="value"></div>
</div>
<div class="swatch">
<div class="rgb">RGB</div>
</div>
</div>
<div class="support-warning">
Sorry, your browser doesn't support Houdini stuff so you won't see the animations. Try Chrome, Edge, or Opera.
</div>
@property --red {
syntax: '<integer>';
inherits: true;
initial-value: 0;
}
@property --green {
syntax: '<integer>';
inherits: true;
initial-value: 0;
}
@property --blue {
syntax: '<integer>';
inherits: true;
initial-value: 0;
}
@keyframes red-fade {
50% { --red: 255; }
}
@keyframes green-fade {
50% { --green: 255; }
}
@keyframes blue-fade {
50% { --blue: 255; }
}
:root {
animation: red-fade 16s, green-fade 14s, blue-fade 12s;
animation-iteration-count: infinite;
}
*, *::before, *::after {
box-sizing: border-box;
}
body {
display: grid;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
padding: 20px;
color: #fff;
background-color: #333;
background-image: linear-gradient(135deg, #111, #444);
font: bold 1.25rem/1 'Roboto Mono', monospace;
}
.wrapper {
display: grid;
grid-template-columns: repeat(3, 40px) minmax(0, 50%);
justify-content: space-around;
gap: 10px;
width: 600px;
max-width: calc(100vw - 40px);
padding: 20px;
border-radius: 20px;
background-color: #0006;
}
.widget {
display: grid;
grid-template-rows: auto max-content max-content;
justify-items: center;
gap: 10px;
}
.bar {
display: grid;
width: 40px;
height: 257px;
border-radius: 5px;
border: 1px solid #fff;
background-color: #fff;
}
.indicator {
align-self: end;
height: 4px;
margin: -2px -6px;
border-radius: 2px;
background-color: #fff;
}
.value::before {
content: counter(color-value);
}
/* red */
.red .bar {
background-image: linear-gradient(to bottom, red, black);
}
.red .indicator {
transform: translateY(calc(var(--red) * -1px));
}
.red .value::before {
counter-reset: color-value var(--red);
}
/* green */
.green .bar {
background-image: linear-gradient(to bottom, lime, black); /* lime, not green! */
}
.green .indicator {
transform: translateY(calc(var(--green) * -1px));
}
.green .value::before {
counter-reset: color-value var(--green);
}
/* blue */
.blue .bar {
background-image: linear-gradient(to bottom, blue, black);
}
.blue .indicator {
transform: translateY(calc(var(--blue) * -1px));
}
.blue .value::before {
counter-reset: color-value var(--blue);
}
.swatch {
background-color: rgb(var(--red), var(--green), var(--blue));
justify-self: stretch;
align-self: center;
display: grid;
justify-content: center;
align-items: center;
height: 257px;
border-radius: 5px;
border: 1px solid #fff;
font-size: 3rem;
}
.rgb {
mix-blend-mode: exclusion;
color: #fff;
}
.support-warning {
display: none;
}
@supports not (background: paint(something)) {
.support-warning {
display: block;
position: absolute;
top: 0;
right: 0;
left: 0;
padding: 20px;
color: #000;
background-color: #fff;
text-align: center;
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.