Issue
I want to style radio input INSIDE "label" tags. I already changed the background color, however when im clicking on my radio white dot inside doesn't show up. I wrote a code for that and I really don't know what the problem is.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
label {
display: inline-block;
cursor: pointer;
position: relative;
padding-left: 25px;
margin-right: 15px;
font-size: 13px;
display:block;
}
input[type=radio] {
display: none;
}
label:before {
content: "";
display: inline-block;
width: 17px;
height: 17px;
margin-right: 10px;
position: absolute;
left: 0;
bottom: 1px;
background-color: #ff7900;
box-shadow: inset 0px 2px 3px 0px rgba(0, 0, 0, .3), 0px 1px 0px 0px rgba(255, 255, 255, .8);
border-radius: 8px;
}
input[type=radio]:checked + label:before {
content: "\2022";
color: #f3f3f3;
font-size: 30px;
text-align: center;
line-height: 18px;
position: absolute;
}
.input {
font-size: 20px;
font-weight: bold;
}
</style>
</head>
<body>
<form>
<label class="input"><input type="radio" name="number" class="hehe">xxxxxxxx</label>
<label class="input" ><input type="radio" name="number" class="hehe">xxxxxxx</label>
<label class="input"><input type="radio" name="number" class="hehe">xxxxxxx</label>\
<label class="input"><input type="radio" name="number" class="hehe">xxxxxxx</label>
</form>
</body>
</html>
Solution
This:
input[type=radio]:checked + label:before
requires that the label
immediately follow the input.
However, your HTML is
<label class="input"><input type="radio" name="number" class="hehe">xxxxxxxx</label>
The label surrounds the input and so the selector will not work.
You would need
<input type="radio" name="number" class="hehe"/><label class="input">xxxxxxxx</label>
Alternatively; use a pseudo-element on a span
inside the label rather than the label itself
<label class="input">
<input type="radio" name="number" class="hehe">
<span>xxxxxxxx</span>
</label>
with
input[type=radio]:checked + span:before
Answered By - Paulie_D
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.