Goal: Successfully pass a variable as a parameter to nth-child. In the example below, the third line should turn green.
Problem: Currently the parameter is ignored as a variable.
Question: Is this possible at all? If yes, what do I have to change?
Example Code:
:root {
--n: 3;
}
div p:nth-child(var(--n)) {
background: green;
padding: 10px;
}
<div>
<p>a</p>
<p>b</p>
<p>c</p>
</div>