<h4>click or tap on any adjacent boxes</h4>
<main>
<input type=checkbox>
<input type=checkbox>
<input type=checkbox>
<input type=checkbox>
<input type=checkbox>
<input type=checkbox checked>
<input type=checkbox checked>
<input type=checkbox>
<input type=checkbox>
<input type=checkbox>
<input type=checkbox>
<input type=checkbox>
<input type=checkbox>
<input type=checkbox>
<input type=checkbox>
<input type=checkbox>
<input type=checkbox>
<input type=checkbox>
<input type=checkbox>
<input type=checkbox>
</main>
input {
display: grid;
width: 60px; height: 40px; margin: 0;
appearance: none; -webkit-appearance: none;
cursor: pointer;
background: #ddd;
border-radius: 20px;
}
input:not(:nth-of-type(4n+1))::before,
input:nth-of-type(n+5)::after {
content: '';
border-radius: 20px;
pointer-events: none;
grid-area: 1/1;
}
input:not(:nth-of-type(4n+1))::before { transform: translatex(-85px); }
input:nth-of-type(n+5)::after { transform: translatey(-60px); }
input:checked { background: limegreen; }
/* a checked box's right borders */
input:not(:nth-of-type(4n)):checked + input:checked::before {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
background: limegreen;
}
/* a checked box's bottom borders */
input:nth-last-of-type(n+5):checked + * + * + * + input:checked::after {
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
background: limegreen;
}
/* a checked box's adjacent (rightside) checked box's left borders */
input:not(:nth-of-type(4n)):checked + input:checked + input::before {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
background: limegreen;
}
/* a checked box's adjacent (below) checked box's top borders */
input:not(:nth-of-type(4n)):checked + * + * + * + input:checked + input::before {
border-top-left-radius: 0;
border-top-right-radius: 0;
background: limegreen;
}
/* a checked box's (in last column) left borders */
input:nth-of-type(4n-1):checked + input:checked {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
/* a checked box's (in last column) adjacent (below) checked box's top borders */
input:nth-of-type(4n):checked + * + * + * + input:checked {
border-top-left-radius: 0;
border-top-right-radius: 0;
}
main {
display: grid;
grid: repeat(5, 60px) / repeat(4, 85px);
align-items: center; justify-items: center;
margin: 0;
}
h4 {
font-family: courier new;
margin:0;
margin-bottom: 10px;
color: darkslategray;
}
body {
display: grid;
grid-template-rows: min-content min-content;
margin-top: 25vh;
align-items: center; justify-items: center;
user-select: none; -webkit-user-select: none;
-webkit-tap-highlight-color: transparent;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.