<fieldset class="rgb">
<label class="r">R:<input type="number" name="r" min="0" max="255" value="255"></label>
<label class="g">G:<input type="number" name="g" min="0" max="255" value="255"></label>
<label class="b">B:<input type="number" name="b" min="0" max="255" value="255"></label>
<output class="rg">R+G</output>
<output class="rb">R+B</output>
<output class="gb">G+B</output>
</fieldset>
body {
--r: 255;
--g: 255;
--b: 255;
background-color: rgb(var(--r), var(--g), var(--b));
font-family: Bahnschrift, 'DIN Alternate', 'Franklin Gothic Medium', 'Nimbus Sans Narrow', sans-serif-condensed, sans-serif;
font-smoothing: antialiased;
osx-font-smoothing: grayscale;
mix-blend-mode: darken;
}
.r, .g, .b {
aspect-ratio: 1 / 1;
border-radius: 50%;
display: grid;
font-size: 5cqi;
mix-blend-mode: color-dodge;
line-height: 1;
place-content: center;
text-align: center;
input {
background: #0000;
border: 2px dotted currentColor;
color: inherit;
font-family: inherit;
font-size: inherit;
outline-color: currentColor;
text-align: center;
&::inner-spin-button {
appearance: none;
}
}
}
.r {
background-color: rgb(var(--r), 0, 0);
color: #FFFC;
grid-area: 1 / 3 / 6 / 8;
}
.g {
background-color: rgb(0, var(--g), 0);
color: #FFFA;
grid-area: 4 / 1 / 9 / 6;
}
.b {
background-color: rgb(0, 0, var(--b));
color: #FFFC;
grid-area: 4 / 5 / 9 / 10;
}
.rg, .rb, .gb {
color: #FFF;
place-content: end;
text-align: center;
}
.rg {
grid-area: 4 / 4 / 5 / 5;
}
.rb {
grid-area: 4 / 6 / 5 / 7;
}
.gb {
grid-area: 6 / 5 / 7 / 6;
place-content: center;
}
.rgb {
all: unset;
aspect-ratio: 9 / 8;
container-type: inline-size;
display: grid;
font-size: 1.75cqi;
grid-template-columns: repeat(9, 1fr);
grid-template-rows: repeat(8, 1fr);
margin-inline: auto;
max-width: 800px;
width: 100%;
}
const rgb = document.querySelector('.rgb');
rgb.addEventListener('input', e => {
const N = e.target;
document.body.style.setProperty(`--${N.name}`, N.value);
})
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.