I want to add some CSS style for ::after when the input is checked.
For example, I want to change the color of 'A' from red
to blue
.
What I tried:
.container::after {
content: 'A';
color: red;
}
.container>input:checked+ ::after {
color: blue;
}
<label class="container">
<input type="checkbox" />
</label>
And:
.container::after {
content: 'A';
color: red;
}
.container>input:checked+.container::after {
color: blue;
}
<label class="container">
<input type="checkbox" />
</label>
Any help would be appreciated.
Thanks!
Edit:
I don't want to modify parent style from the child!
::after is inside the parent. Right along the input.
They're siblings.
You can set below styles for container and they affects the ::after. because it's INSIDE the container.
.container {
display: flex;
justify-content: center;
align-items: center;
}