Answer the question
In order to leave comments, you need to log in
How to refer to an element above in the DOM in CSS?
Good afternoon!
There is a code.
<label class="account-info__type">
<input name="radio" type="radio">
<div>
<span class="account-info__radio"></span>
<p class="account-info__name">Person Account</p>
<p class="account-info__des">A single type of use</p>
</div>
<img src="assets/vector/person.svg" alt="Person Account">
</label>
.account-info__type > input[type=radio]:checked + div > .account-info__radio {
border: 5px solid #249AF3;
}
Answer the question
In order to leave comments, you need to log in
There is no way in CSS to handle a click on an element, let's start with that. And you can’t contact the parent, only from the parent to the child or to the neighbor
Your task is easier to solve, and without js, if I understand its essence correctly:
<input id="input_id" name="radio" type="radio">
<label for="input_id" class="account-info__type">
<div>
<span class="account-info__radio"></span>
<p class="account-info__name">Person Account</p>
<p class="account-info__des">A single type of use</p>
</div>
<img src="assets/vector/person.svg" alt="Person Account">
</label>
input:checked + label {
border: 5px solid #249AF3;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question