Place checkboxes on a horizontal rule with HTML/CSS - html

I am trying to create a web-based rating scale with seven checkboxes, two text labels and a horizontal rule in the background. It should look similar to a paper-based rating scale. In addition, I would like to mark the middle checkbox by a short vertical rule.
Because checkboxes seem to be quite difficult to style, I replaced them by a text symbol and a border in the labels. I manually positioned these checkboxes and the vertical rule on the horizontal rule. The result looks ok in Firefox but it doesn't seem to work for other browsers. In Chrome, IE and Edge, the vertical line is not placed in the center of the scale. Additionally, the checkbox symbol is not centered in Chrome.
Is there a better way to do this?
https://jsfiddle.net/tzuyya36/1/
input[type="radio"] {
display: none;
}
input[type="radio"]+label:before {
font: 12px/16px sans-serif;
text-align: center;
vertical-align: middle;
content: "\00a0";
width: 16px;
height: 16px;
margin: 0;
padding: 0;
position: absolute;
border: 2px solid #8b8d8e;
background: #ffffff;
-webkit-border-radius: 999px;
-moz-border-radius: 999px;
border-radius: 999px;
display: inline-block;
}
input[type="radio"]:checked+label:before {
content: "\26ab";
}
label.scale1 {
cursor: pointer;
margin: 0;
position: absolute;
left: -8px;
}
label.scale2 {
cursor: pointer;
margin: 0;
position: absolute;
left: 82px;
}
label.scale3 {
cursor: pointer;
margin: 0;
position: absolute;
left: 172px;
}
label.scale4 {
cursor: pointer;
margin: 0;
position: absolute;
left: 262px;
}
label.scale5 {
cursor: pointer;
margin: 0;
position: absolute;
left: 352px;
}
label.scale6 {
cursor: pointer;
margin: 0;
position: absolute;
left: 442px;
}
label.scale7 {
cursor: pointer;
margin: 0;
position: absolute;
left: 532px;
}
div.scale {
margin: 20px auto;
width: 540px;
height: 16px;
position: relative;
}
div.leftLabel {
text-align: right;
width: 100px;
position: absolute;
left: -120px;
}
div.rightLabel {
text-align: left;
width: 100px;
position: absolute;
left: 560px;
}
hr.horizontal {
width: 100%;
position: absolute;
border: 2px solid #8b8d8e;
}
hr.vertical {
width: 30px;
position: absolute;
left: 257px;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
border: 2px solid #8b8d8e;
}
<form>
<div class="scale">
<hr class="horizontal">
<hr class="vertical">
<div class="leftLabel">low</div>
<input type="radio" name="test" id="test1" value="1"><label for="test1" class="scale1"></label>
<input type="radio" name="test" id="test2" value="2"><label for="test2" class="scale2"></label>
<input type="radio" name="test" id="test3" value="3"><label for="test3" class="scale3"></label>
<input type="radio" name="test" id="test4" value="4"><label for="test4" class="scale4"></label>
<input type="radio" name="test" id="test5" value="5"><label for="test5" class="scale5"></label>
<input type="radio" name="test" id="test6" value="6"><label for="test6" class="scale6"></label>
<input type="radio" name="test" id="test7" value="7"><label for="test7" class="scale7"></label>
<div class="rightLabel">high</div>
</div>
</form>

Instead of trying to use a symbol which may change in appearance depending on operating system, font etc. I would use another pseudo element. This way you have complete control over the appearance.
To centre the vertical line you would use left: 50%, this way the width of parent is irrelevant, and margin-left: -15px, half the width of the element.
input[type="radio"] {
display: none;
}
input[type="radio"]+label:before {
font: 12px/16px sans-serif;
text-align: center;
vertical-align: middle;
content: "\00a0";
width: 16px;
height: 16px;
margin: 0;
padding: 0;
position: absolute;
border: 2px solid #8b8d8e;
background: #ffffff;
-webkit-border-radius: 999px;
-moz-border-radius: 999px;
border-radius: 999px;
display: inline-block;
}
input[type="radio"]:checked+label:after {
content: "";
width: 12px;
height: 12px;
margin: 4px;
position: absolute;
background: #FF0000;
border-radius: 50%;
}
label.scale1 {
cursor: pointer;
margin: 0;
position: absolute;
left: -8px;
}
label.scale2 {
cursor: pointer;
margin: 0;
position: absolute;
left: 82px;
}
label.scale3 {
cursor: pointer;
margin: 0;
position: absolute;
left: 172px;
}
label.scale4 {
cursor: pointer;
margin: 0;
position: absolute;
left: 262px;
}
label.scale5 {
cursor: pointer;
margin: 0;
position: absolute;
left: 352px;
}
label.scale6 {
cursor: pointer;
margin: 0;
position: absolute;
left: 442px;
}
label.scale7 {
cursor: pointer;
margin: 0;
position: absolute;
left: 532px;
}
div.scale {
margin: 20px auto;
width: 540px;
height: 16px;
position: relative;
}
div.leftLabel {
text-align: right;
width: 100px;
position: absolute;
left: -120px;
}
div.rightLabel {
text-align: left;
width: 100px;
position: absolute;
left: 560px;
}
hr.horizontal {
width: 100%;
position: absolute;
border: 2px solid #8b8d8e;
}
hr.vertical {
height: 30px;
position: absolute;
top: -15px;
left: 50%;
border: 2px solid #8b8d8e;
}
<form>
<div class="scale">
<hr class="horizontal">
<hr class="vertical">
<div class="leftLabel">low</div>
<input type="radio" name="test" id="test1" value="1"><label for="test1" class="scale1"></label>
<input type="radio" name="test" id="test2" value="2"><label for="test2" class="scale2"></label>
<input type="radio" name="test" id="test3" value="3"><label for="test3" class="scale3"></label>
<input type="radio" name="test" id="test4" value="4"><label for="test4" class="scale4"></label>
<input type="radio" name="test" id="test5" value="5"><label for="test5" class="scale5"></label>
<input type="radio" name="test" id="test6" value="6"><label for="test6" class="scale6"></label>
<input type="radio" name="test" id="test7" value="7"><label for="test7" class="scale7"></label>
<div class="rightLabel">high</div>
</div>
</form>

because I like flex, box shadows & gradients.
This way you can add as many inputs you want and the layout will adapt.
form {
display: flex;
}
form > div {
margin: 0 10px;
padding: 10px 0;
}
.scale {
width: 100%;
display: flex;
/* Centering the labels */
justify-content: space-between;
/* Adding the background gray line */
background:linear-gradient(transparent 45%, gray 45%, gray 55%, transparent 55%);
position: relative;
}
/* vertical rule */
.scale::before {
content: '';
position: absolute;
top: 0;
bottom: 0;
width: 4px;
left: 50%;
margin-left: -2px;
background: gray;
z-index: -1;
}
input {
display:none;
}
/* Direct styling of the labels as UTF8 icons can be inconsistent across browsers */
label{
display:block;
width:20px;
height: 20px;
background-color: white;
border: 2px solid gray;
border-radius: 100%;
}
input:checked+label {
/* Inset box-shadows can be used to create additional borders */
box-shadow: inset 0 0 0 2px white;
background-color: gray;
}
<form>
<div>low</div>
<div class="scale">
<input type="radio" name="test" id="test1"><label for="test1"></label>
<input type="radio" name="test" id="test2" checked><label for="test2"></label>
<input type="radio" name="test" id="test3"><label for="test3"></label>
<input type="radio" name="test" id="test4"><label for="test4"></label>
<input type="radio" name="test" id="test5"><label for="test5"></label>
</div>
<div>high</div>
</form>

Don't use hard-coded pixel values, use % here as they are uniformly distributed.
Make 3 divisions. Left label, right label and middle scale. Middle scale is the main focus and left right labels can be done separately.
.scaleContainer {
position: relative;
width: 100%;
}
div.horizontal {
top: 50%;
transform: translateY(-50%);
width: 100%;
height: 3px;
background-color: gray;
position: absolute;
}
div.vertical {
width: 2px;
height: 20px;
background-color: gray;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
input[type="radio"] {
margin: 0;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
}
input[type="radio"]:nth-of-type(1) {
left: calc(100% * 0 / 6)
}
input[type="radio"]:nth-of-type(2) {
left: calc(100% * 1 / 6)
}
input[type="radio"]:nth-of-type(3) {
left: calc(100% * 2 / 6)
}
input[type="radio"]:nth-of-type(4) {
left: calc(100% * 3 / 6)
}
input[type="radio"]:nth-of-type(5) {
left: calc(100% * 4 / 6)
}
input[type="radio"]:nth-of-type(6) {
left: calc(100% * 5 / 6)
}
input[type="radio"]:nth-of-type(7) {
left: calc(100% * 6 / 6)
}
.scale>div {
display: table-cell;
}
.scale>div:first-child,
.scale>div:last-child {
padding: 10px;
}
<form>
<div class="scale">
<div class="leftLabel">low</div>
<div class="scaleContainer">
<div class="horizontal"></div>
<div class="vertical"></div>
<input type="radio" value="1">
<input type="radio" value="2">
<input type="radio" value="3">
<input type="radio" value="4">
<input type="radio" value="5">
<input type="radio" value="6">
<input type="radio" value="7">
</div>
<div class="rightLabel">high</div>
</div>
</form>

Related

Box-shadow and dynamic arrow position for custom select

I found on internet a custom select, made only with HTML and CSS.
* {
position: relative;
margin: 0;
padding: 0;
box-sizing: border-box;
border-color: inherit;
}
form {
width: 114px;
height: 100%;
padding-bottom: 75px;
display: flex;
justify-content: center;
align-items: center;
margin-left: 30px;
}
ul {
list-style: none;
}
.select {
width: 225px;
height: 40px;
cursor: pointer;
background-color: white;
box-shadow: 0 2px 0 white;
border-radius: 2px;
}
.select_expand {
width: 0;
height: 40px;
position: absolute;
top: 0;
right: 0;
}
.select_expand::after {
content: '\003E';
position: absolute;
top: 50%;
right: 70px;
transform: translate(-50%, -50%) rotate(90deg) scaleY(1.75);
color: black;
font-size: 10px;
pointer-events: none;
z-index: 2;
transition: all 250ms cubic-bezier(.4, .25, .3, 1);
}
.select_expand:hover::after {
opacity: 1;
}
.select_expand:checked::after {
transform: translate(-50%, -50%) rotate(90deg) scaleX(-1) scaleY(1.75);
}
.select_expandLabel {
display: block;
width: 100%;
height: 40px;
position: absolute;
top: 0;
left: 0;
cursor: pointer;
}
.select_close {
display: none
}
.select_closeLabel {
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
left: 0;
display: none;
}
.select_items {
width: 100%;
position: absolute;
top: 0;
left: 0;
padding-top: 40px;
}
.select_input {
display: none
}
.select_label {
transition: all 250ms cubic-bezier(.4, .25, .3, 1);
display: block;
height: 0;
font-size: 18px;
line-height: 40px;
overflow: hidden;
color: black;
background-color: #fff;
cursor: pointer;
padding-left: 15px;
}
.select_label-placeholder {
height: 40px;
vertical-align: middle;
position: absolute;
top: 0;
padding-left: 15px;
}
.select_expand:checked+.select_closeLabel {
display: block;
box-shadow: 0 15px 30px 10px rgba(0, 0, 0, 0.1);
}
.select_expand:checked+.select_closeLabel+.select_options .select_label {
height: 40px;
}
.select_expand:checked+.select_closeLabel+.select_options .select_label:hover {
background-color: #f7f7f7
}
.select_expand:checked+.select_closeLabel+.select_options+.select_expandLabel {
display: none
}
.select_input:checked+.select_label {
height: 40px;
margin-top: -40px;
}
<form>
<ul class="select">
<li>
<input class="select_close" type="radio" name="awesomeness" id="awesomeness-close" value=""/>
<span class="select_label select_label-placeholder">#</span>
</li>
<li class="select_items">
<input class="select_expand" type="radio" name="awesomeness" id="awesomeness-opener"/>
<label class="select_closeLabel" for="awesomeness-close"></label>
<ul class="select_options">
<li class="select_option">
<input class="select_input" type="radio" name="awesomeness" id="awesomeness-ridiculous"/>
<label class="select_label" for="awesomeness-ridiculous"># ASD</label>
</li>
<li class="select_option">
<input class="select_input" type="radio" name="awesomeness" id="awesomeness-reasonable"/>
<label class="select_label" for="awesomeness-reasonable">E* ERD</label>
</li>
<li class="select_option">
<input class="select_input" type="radio" name="awesomeness" id="awesomeness-lacking"/>
<label class="select_label" for="awesomeness-lacking"># TRF</label>
</li>
<li class="select_option">
<input class="select_input" type="radio" name="awesomeness" id="awesomeness-awesomeless"/>
<label class="select_label" for="awesomeness-awesomeless">% QWE</label>
</li>
</ul>
<label class="select_expandLabel" for="awesomeness-opener"></label>
</li>
</ul>
</form>
I tried to add a box shadow for the open dropdown menu and I did not succed.
Also I want the arrow to have a dynamic position: to be all the time on the right side and to not overlap with the selected option,as it is doing now, and I don't know how to achieve this one. Is this possible only with css?
I am planning to use this form in a reactjs component.
Here is the JSFiddle link (HTML and CSS).
Could you please help me?
Thank you!
Update
Desired output:
I want that the arrow to move automaticaly to the right of the selected option. I tried with float: right, but not any results.
Maybe it is better to use an image here: content: '\003E';?
* {
position: relative;
margin: 0;
padding: 0;
box-sizing: border-box;
border-color: inherit;
}
form {
width: 114px;
height: 100%;
padding-bottom: 75px;
display: flex;
justify-content: center;
align-items: center;
margin-left: 30px;
}
ul {
list-style: none;
}
.select {
width: 225px;
height: 40px;
cursor: pointer;
background-color: white;
box-shadow: 0 2px 0 white;
border-radius: 2px;
}
.select_expand {
width: 0;
height: 40px;
position: absolute;
top: 0;
right: 0;
}
.select_expand::after {
content: '\003E';
position: absolute;
top: 50%;
right: 25px;
transform: translate(-50%, -50%) rotate(90deg) scaleY(1.75);
color: black;
font-size: 10px;
pointer-events: none;
z-index: 2;
transition: all 250ms cubic-bezier(.4, .25, .3, 1);
}
.select_expand:hover::after {
opacity: 1;
}
.select_expand:checked::after {
transform: translate(-50%, -50%) rotate(90deg) scaleX(-1) scaleY(1.75);
}
.select_expandLabel {
display: block;
width: 100%;
height: 40px;
position: absolute;
top: 0;
left: 0;
cursor: pointer;
}
.select_close {
display: none
}
.select_closeLabel {
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
left: 0;
display: none;
}
.select_items {
width: 100%;
position: absolute;
top: 0;
left: 0;
padding-top: 40px;
}
.select_input {
display: none;
}
.select_label {
transition: all 250ms cubic-bezier(.4, .25, .3, 1);
display: block;
height: 0;
font-size: 18px;
line-height: 40px;
overflow: hidden;
color: black;
background-color: #fff;
cursor: pointer;
padding-left: 15px;
}
.select_label-placeholder {
height: 40px;
vertical-align: middle;
position: absolute;
top: 0;
padding-left: 15px;
}
.select_expand:checked+.select_closeLabel {
display: block;
}
.select_expand:checked+.select_closeLabel+.select_options .select_label:hover {
background-color: #f7f7f7;
}
.select_expand:checked+.select_closeLabel+.select_options+.select_expandLabel {
display: none;
}
.select_input:checked+.select_label {
height: 40px;
margin-top: -40px;/*changed*/
}
.select_expand:checked+.select_closeLabel+.select_options .select_label {
height: 40px;
/*box-shadow: 0 15px 30px 10px rgba(0, 0, 0, 0.1);*/
}
.select_options {
/*coment the below line and uncoment above for diffrent effect*/
box-shadow: 0 15px 30px 10px rgba(0, 0, 0, 0.1);
}
<form>
<ul class="select">
<li>
<input class="select_close" type="radio" name="awesomeness" id="awesomeness-close" value=""/>
<span class="select_label select_label-placeholder">#</span>
</li>
<li class="select_items">
<input class="select_expand" type="radio" name="awesomeness" id="awesomeness-opener"/>
<label class="select_closeLabel" for="awesomeness-close"></label>
<ul class="select_options">
<li class="select_option">
<input class="select_input" type="radio" name="awesomeness" id="awesomeness-ridiculous"/>
<label class="select_label" for="awesomeness-ridiculous"># ASD</label>
</li>
<li class="select_option">
<input class="select_input" type="radio" name="awesomeness" id="awesomeness-reasonable"/>
<label class="select_label" for="awesomeness-reasonable">E* ERD</label>
</li>
<li class="select_option">
<input class="select_input" type="radio" name="awesomeness" id="awesomeness-lacking"/>
<label class="select_label" for="awesomeness-lacking"># TRF</label>
</li>
<li class="select_option">
<input class="select_input" type="radio" name="awesomeness" id="awesomeness-awesomeless"/>
<label class="select_label" for="awesomeness-awesomeless">% QWE</label>
</li>
</ul>
<label class="select_expandLabel" for="awesomeness-opener"></label>
</li>
</ul>
</form>
First things first,
and first thing is putting ;
Second,
to put box shadow
add the code to .select_options
Third,
to avoid overlap
change right from 70px to 25px(reduce right means increase left)

Custom radio button cannot center pseudo element

I am trying to create custom radio button, but after trying few centering methods I couldn't centre pseudo element. For some screen sizes, it works fine but sometimes it gets weird.
.custom-radio {
display: none;
}
.custom-radio+label {
position: relative;
display: inline-block;
width: 15px;
height: 15px;
border: 1px solid rgba(0, 0, 0, 0.3);
border-radius: 50%;
}
.custom-radio+label:after {
content: "";
position: absolute;
width: 11px;
height: 11px;
top: 50%;
left: 50%;
transform: translate3d(-50%, -50%, 0);
background: black;
border-radius: 50%;
}
.custom-radio.flex+label {
display: flex;
align-items: center;
justify-content: center;
}
<div class="input-wrapper">
<input type="radio" id='custom-radio' class='custom-radio'>
<label for="custom-radio"></label>
</div>
<div class="input-wrapper">
<input type="radio" id='custom-radio' class='custom-radio flex'>
<label for="custom-radio"></label>
</div>
Actually the issue is your label width and height...its 15px which is odd which preventing to calculate the top:50% and left:50% value from the parent...Try to do it 16px, it will work fine..
.custom-radio {
display: none;
}
.custom-radio+label {
position: relative;
display: inline-block;
width: 16px;
height: 16px;
border: 1px solid rgba(0, 0, 0, 0.3);
border-radius: 50%;
}
.custom-radio+label:after {
content: "";
position: absolute;
width: 11px;
height: 11px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: black;
border-radius: 50%;
}
<div class="input-wrapper">
<input type="radio" id='custom-radio' class='custom-radio'>
<label for="custom-radio"></label>
</div>
<div class="input-wrapper">
<input type="radio" id='custom-radio' class='custom-radio'>
<label for="custom-radio"></label>
</div>
Well if you don't want to change the width and height of label use Flexbox display:flex in label and margin:auto in :after to align it center vertically and horizontally...
.custom-radio {
display: none;
}
.custom-radio+label {
position: relative;
width: 15px;
height: 15px;
border: 1px solid rgba(0, 0, 0, 0.3);
border-radius: 50%;
display: flex;
}
.custom-radio+label:after {
content: "";
width: 11px;
height: 11px;
background: black;
border-radius: 50%;
margin: auto;
}
<div class="input-wrapper">
<input type="radio" id='custom-radio' class='custom-radio'>
<label for="custom-radio"></label>
</div>
<div class="input-wrapper">
<input type="radio" id='custom-radio' class='custom-radio'>
<label for="custom-radio"></label>
</div>

Pure CSS & HTML Select Dropdown form (with labels)

Made the following pen which is working just fine in any of the up to date browsers (incl. IE11) on a Windows PC. Could anyone tell me why is it not working on a Mac?
as in why exactly does :focus work differently and how does it work differently (it actually works in Chrome on Mac; but not on Safari & Firefox)
.fs_container {
width: 12rem;
position: relative;
}
#dropdown {
opacity: 0;
position: absolute;
z-index: -1;
}
.fs_select {
border: 1px solid grey;
padding: 5px 10px;
width: 100%;
display: block;
box-sizing: border-box;
border-radius: 3px;
background: white;
position: relative;
z-index: 0;
}
.blocker {
position: absolute;
top: 0;
left: 0;
background: transparent;
z-index: -2;
}
.fs_dropdown {
opacity: 0;
list-style: none;
padding: 0;
border: 1px solid grey;
border-top: none;
width: 100%;
box-sizing: border-box;
margin: 0;
border-radius: 3px;
}
.fs_dropdown label {
background: #FF530D;
padding: 4px 10px;
box-sizing: border-box;
width: 100%;
display: block;
border-bottom: 2px dashed #E82C0C;
}
.fs_dropdown li:last-of-type label {
border-bottom: none;
}
#dropdown:focus ~ ul {
opacity: 1;
}
#dropdown:focus ~ div.blocker {
z-index: 2;
}
.fs_selections input {
opacity: 0;
position: absolute;
z-index: -1;
}
.fs_selections label.selected {
position: absolute;
top: 1px;
left: 2px;
padding: 5px 10px;
width: 90%;
box-sizing: border-box;
opacity: 0;
background: white;
}
.fs_selections input:checked + label.selected {
opacity: 1;
}
<div class="fs_container">
<input type="checkbox" id="dropdown" />
<label for="dropdown" class="fs_select">Select</label>
<div class="fs_select blocker"> </div>
<ul class="fs_dropdown">
<li><label for="fa">Option a</label></li>
<li><label for="fb">Option b</label></li>
<li><label for="fc">Option c</label></li>
</ul>
<div class="fs_selections">
<input type="radio" value="Option a" name="languages" id="fa" />
<label for="dropdown" class="selected">Option a</label>
<input type="radio" value="Option b" name="languages" id="fb" />
<label for="dropdown" class="selected">Option b</label>
<input type="radio" value="Option c" name="languages" id="fc" />
<label for="dropdown" class="selected">Option c</label>
</div>
</div>

How to style a radio button with border and color

What is the best way to give a different color of my radio button as well the border color?
I tried using this code but it does not seem to work perfectly.
li.payment_method_bacs input[type='radio']:checked:before {
background: black !important;
content: "";
display: block;
position: relative;
top: 19px;
left: 3px;
width: 6px;
height: 6px;
border-radius: 50%;
border: 3px solid black;
}
li.payment_method_bacs input[type='radio']:checked:before {
background: black !important;
content: "";
display: block;
position: relative;
top: 19px;
left: 3px;
width: 6px;
height: 6px;
border-radius: 50%;
border: 3px solid black;
}
<input id="payment_method_bacs" type="radio" class="input-radio" name="payment_method" value="bacs" data-order_button_text="" checked="checked">
You are applying :after and :before on the input element which is invalid with css. So you need to wrap other things like a div to achieve this. The div will use the checked value of radio and with :after and :before element will do the thing as needed. I am using 2 approaches.
Approach 1: using div as faux element:
li {
list-style: none; display:inline-block; margin-right:20px;
}
.radioBox {
position: relative;
background: transparent;
z-index: 1;
width: 13px;
height: 13px;
cursor: pointer;
}
.radioBox>div {
position: absolute;
z-index: 0;
top: 0;
left: 0;
width: 13px;
height: 13px;
display: inline-block;
border: 2px solid black;
border-radius: 12px;
}
.radioBox>input {
position: absolute;
z-index: 2;
width: 13px;
height: 13px;
opacity: 0;
}
.radioBox > input:checked + div:after {
position: absolute;
content: " ";
font-size: 0;
display: block;
left: 1px;
top: 1px;
width: 10px;
height: 10px;
background: black;
border-radius: 10px;
}
<ul>
<li class="payment_method_bacs">
<div class="radioBox "><input id="payment_method_bacs" type="radio" class="input-radio" name="payment_method" value="bacs" data-order_button_text="" >
<div></div>
</div>
</li>
<li>
<div class="radioBox ">
<input id="payment_method_bacs1" type="radio" class="input-radio" name="payment_method" value="bacs" data-order_button_text="" checked="checked" >
<div></div>
</div>
</li>
</ul>
Approach 2 : Using label as faux element.
ul,li{list-style:none; display:inline-block;}
label {
display: inline-block;
cursor: pointer;
position: relative;
padding-left: 25px;
margin-right: 15px;
font-size: 13px;
}
input[type=radio] {
display: none;
}
label:before {
content: "";
display: inline-block;
width: 16px;
height: 16px;
margin-right: 10px;
position: absolute;
left: 0;
bottom: 1px;
background-color: #fff;
border:1px solid #000;
border-radius:50%;
}
.radio label:before {
border-radius: 8px;
}
input[type=radio]:checked + label:before {
content: "\2022";
color: #000;
font-size: 30px;
text-align: center;
line-height: 18px;
}
<ul>
<li>
<div class="radio">
<input id="payment_method_bacs" type="radio" class="input-radio" name="payment_method" value="bacs" data-order_button_text="" checked="checked">
<label for="payment_method_bacs">Visa</label>
</div>
</li>
<li>
<div class="radio">
<input id="payment_method_bacs1" type="radio" class="input-radio" name="payment_method" value="bacs" data-order_button_text="" >
<label for="payment_method_bacs1">Paypal</label>
</div>
</li>
</ul>
add html in input and lable tag input will be hide if check box will check than you can add style anything in lable
input[type="radio"] {
display: none;
}
input[type="radio"]:checked + label::before {
background: red none repeat scroll 0 0;
border: 0 solid #333;
content: "";
font-size: 0;
height: 20px;
width: 20px;
}
<span class="input-lif in-lidt">
<input class="contact_radio" id="rbsrt1" name="contact" value="individual" checked="checked" type="radio">
<label for="rbsrt1"> Individual </label>
</span>
Changing the appearance of form inputs it's a little bit tricky, as each browser renders them in a different manner.
To ensure you get the same result for different browsers, you might consider using an image (inline, or as a background image for the element containing the input) or an element, as your input display.
<label id="myLabel" for="payment_method_bacs">
<input id="payment_method_bacs"
type="radio"
class="input-radio"
name="payment_method"
value="bacs"
data-order_button_text=""
checked="checked">
</label>
#myLabel{
width: 20px;
height: 20px;
background: white;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;
border-radius: 50px;
border:2px solid #ccc;
display:inline-block;
}
#myLabel input{
display:none;
}
Fiddle provided here: https://jsfiddle.net/omfv8qhj/

Erased border with the scale

There stylized input, but the zoom in / out, they change size, it seems as if the border is lost, I can't understand what went wrong, thanks in advance.
My codepen
For example, Chrome - zoom 75%
<div class="checkbox-remember-me">
<input type="radio" name="gender" id="male" checked/>
<label for="male"></label>
</div>Male
This happens because you use an absolute positioned label to cover its parent partially to make it appear to have a border, and when the page is zoomed, depending on how the browser calculate its position, it jumps a pixel up and down, hence sometimes fully aligns with its parent's edge.
Update your css like this, and use a border instead, and it will work fine.
.checkbox-remember-me {
display: inline-block;
width: 24px;
height: 24px;
position: relative;
border: 1px solid #666;
margin-left: 34px;
margin-right: 10px;
}
.checkbox-remember-me label {
width: 22px;
height: 22px;
cursor: pointer;
position: absolute;
background: #eee;
margin: 1px;
}
.checkbox-remember-me {
display: inline-block;
width: 24px;
height: 24px;
position: relative;
border: 1px solid #666;
margin-left: 34px;
margin-right: 10px;
}
.checkbox-remember-me label {
width: 22px;
height: 22px;
cursor: pointer;
position: absolute;
background: #eee;
margin: 1px;
}
.checkbox-remember-me label:after {
content: '';
width: 15px;
height: 10px;
position: absolute;
top: 4px;
left: 4px;
border: 3px solid red;
border-top: none;
border-right: none;
background: transparent;
opacity: 0;
transform: rotate(-45deg);
}
.checkbox-remember-me label:hover:after {
opacity: 0.3;
}
input[type=radio] {
display: none;
}
input[type=radio]:checked + label:after {
opacity: 1;
}
<h4>Gender</h4>
<div class="checkbox-remember-me">
<input type="radio" name="gender" id="male" checked/>
<label for="male"></label>
</div>Male
<div class="checkbox-remember-me">
<input type="radio" name="gender" id="female" />
<label for="female"></label>
</div>Female
Updated codepen: https://codepen.io/anon/pen/LRLrNO