Custom Radio Button Using Css
I am trying to create the custom radio button as shown in the picture below. I wrote the code and able to achieve the correct styling but not able to make the label appear before
Solution 1:
Replace before
with after
and vice-versa for span
and yeah, margin-left
with margin-right
:
.lengend-action-buttons {
float: left;
margin-left: 10px;
margin-top: 10px;
}
label {
font-weight: normal;
font-size: 14px;
Font-Family: Metric-Regular;
Color: #666666;
display: block;
cursor: pointer;
}
[type="radio"] {
border: 0;
clip: rect(0000);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
[type="radio"] + span:after {
content: '';
display: inline-block;
width: 1.1em;
height: 1.1em;
vertical-align: -0.10em;
border-radius: 1em;
border: 0.35em solid #fff;
box-shadow: 0000.10em#36B18D;
margin-left: 0.75em;
transition: 0.5s ease all;
}
[type="radio"]:checked + span:after {
background: #36B18D;
box-shadow: 0000.10em#36B18D;
}
[type="radio"]:focus + span::before {
font-size: 1.2em;
line-height: 1;
vertical-align: -0.125em;
}
<divclass="lengend-action-buttons lengend-action-buttons-first"><labelfor="d3_graph_chart0011day"><inputtype="radio"name="date_range"id="d3_graph_chart0011day"value="1day"checked="checked"><span>1 Day</span></label></div><divclass="lengend-action-buttons lengend-action-buttons-first"><labelfor="d3_graph_chart0017day"><inputtype="radio"name="date_range"id="d3_graph_chart0017day"value="7day"><span>7 Day</span></label></div><divclass="lengend-action-buttons lengend-action-buttons-first"><labelfor="d3_graph_chart00130day"><inputtype="radio"name="date_range"id="d3_graph_chart00130day"value="30day"><span>30 Day</span></label></div><divclass="lengend-action-buttons lengend-action-buttons-first"><labelfor="d3_graph_chart00190day"><inputtype="radio"name="date_range"id="d3_graph_chart00190day"value="901day"><span>90 Day</span></label></div>
Solution 2:
replace :before
with :after
to make the text middle aligned set vertical-align
to middle
.lengend-action-buttons {
float: left;
margin-left: 10px;
margin-top: 10px;
}
label {
font-weight: normal;
font-size: 14px;
Font-Family: Metric-Regular;
Color: #666666;
display: block;
cursor: pointer;
}
[type="radio"] {
border: 0;
clip: rect(0000);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
[type="radio"] + span:after {
content: '';
display: inline-block;
width: 1.1em;
height: 1.1em;
vertical-align: middle;
border-radius: 1em;
border: 0.35em solid #fff;
box-shadow: 0000.10em#36B18D;
margin-left: 0.75em;
transition: 0.5s ease all;
}
[type="radio"]:checked + span:after {
background: #36B18D;
box-shadow: 0000.10em#36B18D;
}
[type="radio"]:focus + span::before {
font-size: 1.2em;
line-height: 1;
vertical-align: middle;
}
<divclass="lengend-action-buttons lengend-action-buttons-first"><labelfor="d3_graph_chart0011day"><inputtype="radio"name="date_range"id="d3_graph_chart0011day"value="1day"checked="checked"><span>1 Day</span></label></div><divclass="lengend-action-buttons lengend-action-buttons-first"><labelfor="d3_graph_chart0017day"><inputtype="radio"name="date_range"id="d3_graph_chart0017day"value="7day"><span>7 Day</span></label></div><divclass="lengend-action-buttons lengend-action-buttons-first"><labelfor="d3_graph_chart00130day"><inputtype="radio"name="date_range"id="d3_graph_chart00130day"value="30day"><span>30 Day</span></label></div><divclass="lengend-action-buttons lengend-action-buttons-first"><labelfor="d3_graph_chart00190day"><inputtype="radio"name="date_range"id="d3_graph_chart00190day"value="901day"><span>90 Day</span></label></div>
Post a Comment for "Custom Radio Button Using Css"