<select id="repeatSelect" name="repeat" class="repeat-type">
<option value="repeat">repeat</option>
<option value="repeat-x">repeat-x</option>
<option value="repeat-y">repeat-y</option>
<option value="no-repeat">no-repeat</option>
<option value="round">round</option>
<option value="space">space</option>
<option value="round no-repeat">round no-repea</option>
<option value="no-repeat space">no-repeat space</option>
</select>
:root {
&:has(select [value="repeat"]:checked) { --repeat: repeat; }
&:has(select [value="repeat-x"]:checked) { --repeat: repeat-x; }
&:has(select [value="repeat-y"]:checked) { --repeat: repeat-y; }
&:has(select [value="no-repeat"]:checked) { --repeat: no-repeat; }
&:has(select [value="round"]:checked) { --repeat: round; }
&:has(select [value="space"]:checked) { --repeat: space; }
&:has(select [value="round no-repeat"]:checked) { --repeat: round no-repeat; }
&:has(select [value="no-repeat spacee"]:checked) { --repeat: no-repeat space; }
}
* {
box-sizing: border-box;
margin: 0 auto;
}
body {
background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/308367/star.svg);
background-repeat: var(--repeat);
display: grid;
height: 100dvh;
align-items: center;
}
select {
background: #fff;
font-size: 30px;
margin-block-start: 1rem;
padding: 1rem;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.