1
I’m hiding the <input type="radio">
with class sr-only
of bootstrap
, and the problem that occurs is this:
With class
sr-only
active:- The
radio
are not unchecked if I click the other - The
.card
gets colored when you click
- The
Classless
sr-only
:- The
radio
are unchecked if I click the other - The
.card
does not get colored when clicking
- The
What I’m trying to do is simply this:
- By clicking on the given
input
, will be colored with the attributebackground-color
the same.
Why is this happening and how to solve?
HTML
<div class="form-group col-6">
<label for="step-one-form-sex-male" data-for="step-one-form-sex-male" style="width: 100% !important;">
<input type="radio" name="step-one-form-personal-information-sex" value="Male">
<div class="card">
<div class="card-body text-center">
<img src="./dist/img/doctor_male.png" alt="" style="width: 4rem">
</div>
<div class="card-footer text-center py-2">
<h7 class="card-title font-weight-bold" style="font-size: .87rem"> SOU HOMEM</h7>
</div>
</div>
</label>
</div>
<div class="form-group col-6">
<label for="step-one-form-sex-female" id="tst" data-for="step-one-form-sex-female" style="width: 100% !important;">
<input type="radio" name="step-one-form-personal-information-sex" value="Female" class="sr-only">
<div class="card">
<div class="card-body text-center">
<img src="./dist/img/doctor_female.png" alt="" style="width: 4rem">
</div>
<div class="card-footer text-center py-2">
<h7 class="card-title font-weight-bold" style="font-size: .87rem">
SOU MULHER
</h7>
</div>
</div>
</label>
</div>
SASS
label {
&[data-for="step-one-form-sex-female"] {
& {
input {
&:checked + .card {
@include createBorder('rounded', solid, 1px, #FF648F);
.card-footer {
@include createColor('light-rose-1', background-color);
@include createColor('white', color);
}
}
}
}
&:hover {
@include media-breakpoint-lg {
.card {
@include createBorder('rounded', solid, 1px, #FF648F);
@include createShadow(box-shadow, 'regular');
.card-footer {
@include createColor('light-rose-1', background-color);
@include createColor('white', color);
}
}
}
}
}
}
Instead of putting SASS, you could put the final CSS, it helps a lot to play the scenario.
– Sam
Interesting fact: you are using SASS, but you have defined several properties with CSS inline; you did this for some specific reason?
– Woss
@Sam would get too big the code.
– user148754