0
I am trying to change the border of an image when the input of a checkbox is selected, or my css does not leave or something is blocking. Following the logic I tested these css lines and no one gave to put the border to change .
input:checked + li {
border: solid rgba(37,205,61,1.00);
}
input:checked + #field_1_5 {
border: solid rgba(37,205,61,1.00);
}
input:checked + li .list {
border: solid rgba(37,205,61,1.00);
}
input:checked + .list {
border: solid rgba(37,205,61,1.00);
}
What I want is for both the outside border and the image border to be green by clicking on the image (checkbox) and not working I leave here to download my html and css .
}
.list img {
border: solid rgba(223, 223, 223, 0.99);
}
.list {
list-style-type: none;
margin-left: 150px;
padding-left: 0px;
display: inline-block;
border: solid rgba(223, 223, 223, 0.99);
text-align: center;
width: 305px;
background-color: rgba(237, 237, 237, 1.00);
}
ul {
list-style-type: none;
}
#field_1_5 {
display: none;
/* visibility: hidden works too */
}
<ul>
<li class="list">
<label class="" for="field_1_5">
<span class="">
<img src="https://image.freepik.com/free-vector/vector-illustration-of-a-mountain-landscape_1441-77.jpg" alt="imagem montanha" width="300" title="montanha">
</span>
<br>
<input type="checkbox" id="field_1_5" name="check1[]" value="Montras Digitais">
<span class="">imagem montanha</span>
</label>
</li>
</ul>
Is the first CSS not good for anything? Why is it not part of the second code?
– Sam
With
input:checked + li
you are selecting the element<li>
adjacent to theinput:checked
, but in its case the<li>
is the father ofinput
. In CSS, we currently have no way to select parent elements from the child.– Woss
then it means I can’t get this to work ??
– joao dias