Inner spacing inside rounded checkbox [duplicate] - html

This question already has answers here:
How to create multiple borders around existing border of circle [duplicate]
(2 answers)
Closed 3 years ago.
I'm trying to achieve this:
I've also managed to get the result, but I cannot add the spacing between the grey border and blue circle:
input {
line-height: normal;
&[type="checkbox"],
&[type="radio"] {
width: 1.3em;
height: 1.3em;
background-color: white;
border-radius: 50%;
vertical-align: middle;
border: 1px solid #ddd;
border-width: thick;
-webkit-appearance: none;
outline: none;
cursor: pointer;
}
}

Use border: 2px solid white; for the white ring, and box-shadow: 0 0 0 2px #ddd; for the outer grey ring.
Then you can set background-color to white for unchecked or #73c0ec for checked.
input[type="radio"] {
width: 1.3em;
height: 1.3em;
background-color: white;
border-radius: 50%;
border: 2px solid white;
box-shadow: 0 0 0 2px #ddd;
-webkit-appearance: none;
cursor: pointer;
}
input[type="radio"]:checked {
background-color: #73c0ec;
}
<input type="radio" name="group-1"><br>
<input type="radio" name="group-1"><br>
<input type="radio" name="group-1">

I think you are looking for custom radio style like this
.radio-custom {
opacity: 0;
position: absolute;
}
.radio-custom, .radio-custom-label {
display: inline-block;
vertical-align: middle;
margin: 5px;
cursor: pointer;
}
.radio-custom-label {
position: relative;
}
.radio-custom + .radio-custom-label:before {
content: '';
background: #fff;
border: 2px solid #ddd;
display: inline-block;
vertical-align: middle;
width: 20px;
height: 20px;
padding: 2px;
margin-right: 10px;
text-align: center;
}
.radio-custom + .radio-custom-label:before {
border-radius: 50%;
}
.radio-custom:checked + .radio-custom-label:before {
background: #ccc;
box-shadow: inset 0px 0px 0px 4px #fff;
}
.radio-custom:focus + .radio-custom-label {
outline: 1px solid #ddd; /* focus style */
}
<form>
<h2>Radio Buttons</h2>
<div>
<input id="radio-1" class="radio-custom" name="radio-group" type="radio" checked>
<label for="radio-1" class="radio-custom-label">First Choice</label>
</div>
<div>
<input id="radio-2" class="radio-custom"name="radio-group" type="radio">
<label for="radio-2" class="radio-custom-label">Second Choice</label>
</div>
<div>
<input id="radio-3" class="radio-custom" name="radio-group" type="radio">
<label for="radio-3" class="radio-custom-label">Third Choice</label>
</div>
</form>

Related

How to display the check mark when choosing the checkbox?

I have a checkbox and I changed the checkbox style in a circle. Now I need when the user chooses the checkbox then I have to display the check mark.
If I remove -webkit-appearance: none; then I am getting it but my css not working.
How can I do this?
.checkbox_round {
width: 18px;
height: 18px;
background-color: white;
border-radius: 50%;
vertical-align: middle;
border: 1px solid #ddd;
outline: none;
cursor: pointer;
-webkit-appearance: none;
}
.checkbox_round:hover {
border-color: #000;
}
.checkbox_round:checked {
background-color: #f00;
}
<label><input type="checkbox" name="name1" value="1" class="checkbox_round"> check box1 </label>
<label><input type="checkbox" name="name2" value="2" class="checkbox_round"> check box1 </label>
<label><input type="checkbox" name="name3" value="3" class="checkbox_round"> check box1 </label>
You could make a checkmark using CSS or just use a unicode checkmark. You can also just add an image, which has already been suggested.
Here are the first two possible ways:
.checkbox_round {
width: 18px;
height: 18px;
background-color: white;
border-radius: 50%;
vertical-align: middle;
border: 1px solid #ddd;
outline: none;
cursor: pointer;
-webkit-appearance: none;
}
.checkbox_round:hover {
border-color: #000;
}
.checkbox_round {
position: relative;
}
.checkbox_round:checked {
background-color: #f00;
}
.checkbox_round:checked:before {
content: "✓";
left: 3px;
top: -2px;
position: absolute;
}
.checkbox2:checked:before {
content: "";
border: 1px solid black;
border-width: 1px 1px 0 0;
height: 5px;
width: 13px;
position: absolute;
transform: rotate(135deg);
left: 3px;
top: 2px;
}
<label><input type="checkbox" name="name1" value="1" class="checkbox_round"> check box1 </label>
<label><input type="checkbox" name="name2" value="2" class="checkbox_round checkbox2"> check box1 </label>
You can use a background image. I suggest you an svg.
.checkbox_round {
width: 18px;
height: 18px;
background-color: white;
border-radius: 50%;
vertical-align: middle;
border: 1px solid #ddd;
outline: none;
cursor: pointer;
-webkit-appearance: none;
}
.checkbox_round:hover {
border-color: #000;
}
.checkbox_round:checked {
background-image: url(https://cdns.iconmonstr.com/wp-content/assets/preview/2012/240/iconmonstr-check-mark-1.png);
background-size: 50%;
background-position: center center;
background-repeat: no-repeat;
}
<label><input type="checkbox" name="name1" value="1" class="checkbox_round"> check box1 </label>

Design Toggle button using Radio buttons

I am trying to develop toggle buttons using plain CSS. My toggle button should look like the below image.
Here is the snippet of the code that I created.
.btn {
display: inline-block;
margin-bottom: 0;
text-align: center;
cursor: pointer;
background-image: none;
border: 1px solid transparent;
white-space: nowrap;
padding: 3px 16px;
font-family: ABBvoice;
font-size: 13px;
font-weight: 500;
border-radius: 0;
height: 30px;
padding-bottom: 7px;
}
.btn-default-toggle-ghost,
.btn-default-toggle-ghost:focus {
background: transparent;
border: 1px solid rgba(160, 160, 160, 0.6);
color: #464646;
outline: none;
}
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default-toggle-ghost active">
<input type="radio" name="test-toggle" checked="checked"> Option 1
</label>
<label class="btn btn-default-toggle-ghost active">
<input type="radio" name="test-toggle"> Option 2
</label>
</div>
Above code displays toggle button as below.
Can someone help me to correct the css in the above code? Any help would be appreciated. Thank you.
This will work for you:
Input can't be styled so, it's better to hide them and style there label as per your need.
.btn {
display: inline-block;
margin-bottom: 0;
text-align: center;
cursor: pointer;
background-image: none;
border: 1px solid transparent;
white-space: nowrap;
padding: 3px 16px;
font-family: ABBvoice;
font-size: 13px;
font-weight: 500;
border-radius: 0;
height: 30px;
padding-bottom: 7px;
}
.btn-default-toggle-ghost,
.btn-default-toggle-ghost:focus {
background: transparent;
border: 1px solid rgba(160, 160, 160, 0.6);
color: #464646;
outline: none;
text-align: center;
font-size: 16px;
line-height: 30px;
position: relative;
float: left;
}
.btn-group [type="radio"] {
display: none;
}
[type="radio"]:checked+.btn-default-toggle-ghost {
background: #DEDEDE;
}
[type="radio"]:checked+.btn-default-toggle-ghost:after {
content: '';
position: absolute;
top: 0px;
height: 3px;
background: #0093F6;
left: 0px;
right: 0px;
}
.btn-default-toggle-ghost+[type="radio"]+.btn-default-toggle-ghost{
border-left:0px;/*for removing the extra border between the buttons*/
}
<div class="btn-group" data-toggle="buttons">
<input type="radio" id="one" name="test-toggle" checked="checked">
<label for="one" class="btn btn-default-toggle-ghost active">
Option 1
</label>
<input type="radio" id="two" name="test-toggle">
<label for="two" class="btn btn-default-toggle-ghost active">
Option 2
</label>
</div>
I hope this works fine for you.
You can check out for attribute for label. Notice that I placed label right after input[type=radio]
.btn {
display: inline-block;
margin-bottom: 0;
text-align: center;
cursor: pointer;
background-image: none;
border: 1px solid transparent;
white-space: nowrap;
padding: 3px 16px;
font-family: ABBvoice;
font-size: 13px;
font-weight: 500;
border-radius: 0;
height: 30px;
padding-bottom: 7px;
}
.btn-default-toggle-ghost, .btn-default-toggle-ghost:focus {
background: transparent;
border: 1px solid rgba(160,160,160, 0.6);
color: #464646;
outline: none;
}
input[type=radio]{
/* comment this out to check if radio input is checked */
display: none;
}
input[type=radio]:checked+label{
background-color: blue;
color: white;
}
<div class="btn-group" data-toggle="buttons">
<input id="option-1" type="radio" name="test-toggle" checked="checked">
<label for="option-1" class="btn btn-default-toggle-ghost active">
Option 1
</label>
<input id="option-2" type="radio" name="test-toggle">
<label for="option-2" class="btn btn-default-toggle-ghost active">
Option 2
</label>
</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/

Check Box / Radio Button line wrap issue

I'm trying to prevent separation of label and check box (or radio button) when there is a line wrap. Unfortunately I'm working with some very long labels over which I have no control.
It would be awesome if there could be columns where all the buttons align, but at a minimum, no splitting up of items.
thanks in advance.
#import url(http://fonts.googleapis.com/css?family=Montserrat);
/*basic reset*/
* {margin: 0; padding: 0;}
.html_S {
height: 100%;
}
.toast {
opacity: 1 !important;
}
.body_S {
min-height: 100%;
margin: 0;
background-repeat: no-repeat;
background-attachment: fixed;
font-family: montserrat, arial, verdana;
background-color: transparent !important;
}
.reqSpan_S {
top: -15px;
position:relative;
}
.reqFieldText_S {
color: red;
padding: 0;
margin: 0;
}
.reqFieldStar_S {
font-weight: bold;
}
.k-button {
color: red;
}
.buttonCentre_S {
text-align: center;
}
.outerDiv_S {
width: 85%;
margin: 50px auto;
text-align: center;
}
#surveyForm {
top: -35px;
position:relative;
width: 85%;
margin: 50px auto;
text-align: left;
}
#surveyForm fieldset {
background: white;
border: 0 none;
border-radius: 3px;
box-shadow: 0 0 15px 1px rgba(0, 0, 0, 0.4);
padding: 20px 30px;
box-sizing: border-box;
width: 80%;
margin: 0 10%;
}
/*inputs*/
#surveyForm input, #surveyForm textarea {
padding: 15px;
border: 1px solid #ccc;
border-radius: 3px;
margin-bottom: 10px;
width: 100%;
box-sizing: border-box;
font-family: montserrat;
color: #2C3E50;
font-size: 13px;
}
/*buttons*/
#surveyForm .action-button {
text-align: center;
width: 100px;
background: #27AE60;
font-weight: bold;
color: white;
border: 0 none;
border-radius: 1px;
cursor: pointer;
padding: 10px 5px;
margin: 10px 5px;
}
#surveyForm .action-button:hover, #surveyForm .action-button:focus {
box-shadow: 0 0 0 2px white, 0 0 0 3px #27AE60;
}
#surveyForm .action-button-submit {
width: 100px;
background: #3498db;
font-weight: bold;
color: white;
border: 0 none;
border-radius: 1px;
cursor: pointer;
padding: 10px 5px;
margin: 10px 5px;
}
/*For Toast not part of surveyForm...*/
.action-button-ok {
width: 100px;
background: rgba(255, 255, 255, 0.3);
font-weight: bold;
color: white;
border: 0 none;
border-radius: 1px;
cursor: pointer;
padding: 10px 5px;
margin: 10px 5px;
}
#surveyForm .action-button-submit:hover, #surveyForm .action-button-submit:focus {
box-shadow: 0 0 0 2px white, 0 0 0 3px #3498db;
}
/*headings*/
.fs-title {
font-size: 15px;
text-transform: uppercase;
color: #2C3E50;
margin-bottom: 10px;
}
.fs-subtitle {
font-weight: normal;
font-size: 13px;
color: #666;
margin-bottom: 20px;
}
/*progressbar*/
#progressbar {
margin-bottom: 30px;
overflow: hidden;
/*CSS counters to number the steps*/
counter-reset: step;
}
#progressbar li {
list-style-type: none;
color: white;
text-transform: uppercase;
font-size: 9px;
/* width should be 100 divided by the number of steps */
/* this is set in the code dynamically in javascript */
width: 6.25%;
float: left;
position: relative;
}
#progressbar li:before {
content: counter(step);
counter-increment: step;
width: 20px;
line-height: 20px;
display: block;
font-size: 10px;
color: #333;
background: white;
border-radius: 3px;
margin: 0 auto 5px auto;
}
/*progressbar connectors*/
#progressbar li:after {
content: '';
width: 100%;
height: 2px;
background: white;
position: absolute;
left: -50%;
top: 9px;
z-index: -1; /*put it behind the numbers*/
}
#progressbar li:first-child:after {
/*connector not needed before the first step*/
content: none;
}
/*marking active/completed steps green*/
/*The number of the step and the connector before it = green*/
#progressbar li.active:before, #progressbar li.active:after{
background: #27AE60;
color: white;
}
.k-dropdown {
width: 100%;
}
.k-state-selected.k-state-focused {
background-color: #27AE60;
border: 0;
}
#surveyForm hr {
border: 0;
height: 0;
border-top: 1px solid rgba(0, 0, 0, 0.1);
border-bottom: 1px solid rgba(255, 255, 255, 0.3);
margin-bottom: 10px;
}
/* https://stackoverflow.com/a/17541916/1550052 */
.rad,
.ckb{
cursor: pointer;
user-select: none;
-webkit-user-select: none;
-webkit-touch-callout: none;
padding: 10px;
}
.rad > input,
.ckb > input{ /* HIDE ORG RADIO & CHECKBOX */
visibility: hidden;
position: absolute;
}
/* RADIO & CHECKBOX STYLES */
.rad > i,
.ckb > i{ /* DEFAULT <i> STYLE */
display: inline-block;
vertical-align: middle;
width: 16px;
height: 16px;
border-radius: 50%;
transition: 0.2s;
box-shadow: inset 0 0 0 8px #fff;
border: 1px solid #d3d3d3;
background: #666;
margin-right: 4px;
}
/* CHECKBOX OVERWRITE STYLES */
.ckb > i {
width: 25px;
border-radius: 3px;
}
.rad:hover > i{ /* HOVER <i> STYLE */
box-shadow: inset 0 0 0 3px #fff;
background: #666;
}
.rad > input:checked + i{ /* (RADIO CHECKED) <i> STYLE */
box-shadow: inset 0 0 0 3px #fff;
background: #27AE60;
}
/* CHECKBOX */
.ckb > input + i:after{
content: "";
display: block;
height: 12px;
width: 12px;
margin: 2px;
border-radius: inherit;
transition: inherit;
background: #d3d3d3;
}
.ckb > input:checked + i:after{ /* (RADIO CHECKED) <i> STYLE */
margin-left: 11px;
background: #27AE60;
}
<body class='body_S'>
<form id='surveyForm'>
<!-- fieldsets -->
<fieldset >
<h2 class="fs-title">
Demographic Search Criteria
</h2>
<h2 class="fs-subtitle">
The demographic data you select here will be used by planners
</h2>
<h2 class="fs-subtitle">
1
</h2>
<label>Main Type of Business
</label>
<br />
<label class="ckb" for="cb-638-0">
<input type="checkbox" name="cb-638" id="cb-638-0" value="3223" />
<i></i>Accommodations
</label>
<label class="ckb" for="cb-638-1">
<input type="checkbox" name="cb-638" id="cb-638-1" value="3224" />
<i></i>Activities, Attractions & Tours
</label>
<label class="ckb" for="cb-638-2">
<input type="checkbox" name="cb-638" id="cb-638-2" value="3225" />
<i></i>Association
</label>
<label class="ckb" for="cb-638-3">
<input type="checkbox" name="cb-638" id="cb-638-3" value="3226" />
<i></i>Convention and Visitors Bureau
</label>
<label class="ckb" for="cb-638-4">
<input type="checkbox" name="cb-638" id="cb-638-4" value="3227" />
<i></i>Convention Centre
</label>
<label class="ckb" for="cb-638-5">
<input type="checkbox" name="cb-638" id="cb-638-5" value="3228" />
<i></i>Cruise Line
</label>
<label class="ckb" for="cb-638-6">
<input type="checkbox" name="cb-638" id="cb-638-6" value="3229" />
<i></i>Destination Management Company
</label>
<label class="ckb" for="cb-638-7">
<input type="checkbox" name="cb-638" id="cb-638-7" value="3230" />
<i></i>Destination Marketing Organization
</label>
<label class="ckb" for="cb-638-8">
<input type="checkbox" name="cb-638" id="cb-638-8" value="3231" />
<i></i>Event Service Provider
</label>
<label class="ckb" for="cb-638-9">
<input type="checkbox" name="cb-638" id="cb-638-9" value="3232" />
<i></i>Technology Provider
</label>
<label class="ckb" for="cb-638-10">
<input type="checkbox" name="cb-638" id="cb-638-10" value="3233" />
<i></i>Transportation
</label>
<label class="ckb" for="cb-638-11">
<input type="checkbox" name="cb-638" id="cb-638-11" value="3234" />
<i></i>Tourism Board
</label>
<label class="ckb" for="cb-638-12">
<input type="checkbox" name="cb-638" id="cb-638-12" value="3235" />
<i></i>Venues for Meeting/Events (non-hotel)
</label>
</fieldset>
</form>
</body>
</html>
css for the select groups starts at line 207 of the css section. Its from this stack overflow solution: https://stackoverflow.com/a/17541916/155005
Add float: left; to you label tags
#import url(http://fonts.googleapis.com/css?family=Montserrat);
/*basic reset*/
* {margin: 0; padding: 0;}
.html_S {
height: 100%;
}
.toast {
opacity: 1 !important;
}
.body_S {
min-height: 100%;
margin: 0;
background-repeat: no-repeat;
background-attachment: fixed;
font-family: montserrat, arial, verdana;
background-color: transparent !important;
}
.reqSpan_S {
top: -15px;
position:relative;
}
.reqFieldText_S {
color: red;
padding: 0;
margin: 0;
}
.reqFieldStar_S {
font-weight: bold;
}
.k-button {
color: red;
}
.buttonCentre_S {
text-align: center;
}
.outerDiv_S {
width: 85%;
margin: 50px auto;
text-align: center;
}
#surveyForm {
top: -35px;
position:relative;
width: 85%;
margin: 50px auto;
text-align: left;
}
#surveyForm fieldset {
background: white;
border: 0 none;
border-radius: 3px;
box-shadow: 0 0 15px 1px rgba(0, 0, 0, 0.4);
padding: 20px 30px;
box-sizing: border-box;
width: 80%;
margin: 0 10%;
}
/*inputs*/
#surveyForm input, #surveyForm textarea {
padding: 15px;
border: 1px solid #ccc;
border-radius: 3px;
margin-bottom: 10px;
width: 100%;
box-sizing: border-box;
font-family: montserrat;
color: #2C3E50;
font-size: 13px;
}
/*buttons*/
#surveyForm .action-button {
text-align: center;
width: 100px;
background: #27AE60;
font-weight: bold;
color: white;
border: 0 none;
border-radius: 1px;
cursor: pointer;
padding: 10px 5px;
margin: 10px 5px;
}
#surveyForm .action-button:hover, #surveyForm .action-button:focus {
box-shadow: 0 0 0 2px white, 0 0 0 3px #27AE60;
}
#surveyForm .action-button-submit {
width: 100px;
background: #3498db;
font-weight: bold;
color: white;
border: 0 none;
border-radius: 1px;
cursor: pointer;
padding: 10px 5px;
margin: 10px 5px;
}
/*For Toast not part of surveyForm...*/
.action-button-ok {
width: 100px;
background: rgba(255, 255, 255, 0.3);
font-weight: bold;
color: white;
border: 0 none;
border-radius: 1px;
cursor: pointer;
padding: 10px 5px;
margin: 10px 5px;
}
#surveyForm .action-button-submit:hover, #surveyForm .action-button-submit:focus {
box-shadow: 0 0 0 2px white, 0 0 0 3px #3498db;
}
/*headings*/
.fs-title {
font-size: 15px;
text-transform: uppercase;
color: #2C3E50;
margin-bottom: 10px;
}
.fs-subtitle {
font-weight: normal;
font-size: 13px;
color: #666;
margin-bottom: 20px;
}
/*progressbar*/
#progressbar {
margin-bottom: 30px;
overflow: hidden;
/*CSS counters to number the steps*/
counter-reset: step;
}
#progressbar li {
list-style-type: none;
color: white;
text-transform: uppercase;
font-size: 9px;
/* width should be 100 divided by the number of steps */
/* this is set in the code dynamically in javascript */
width: 6.25%;
float: left;
position: relative;
}
#progressbar li:before {
content: counter(step);
counter-increment: step;
width: 20px;
line-height: 20px;
display: block;
font-size: 10px;
color: #333;
background: white;
border-radius: 3px;
margin: 0 auto 5px auto;
}
/*progressbar connectors*/
#progressbar li:after {
content: '';
width: 100%;
height: 2px;
background: white;
position: absolute;
left: -50%;
top: 9px;
z-index: -1; /*put it behind the numbers*/
}
#progressbar li:first-child:after {
/*connector not needed before the first step*/
content: none;
}
/*marking active/completed steps green*/
/*The number of the step and the connector before it = green*/
#progressbar li.active:before, #progressbar li.active:after{
background: #27AE60;
color: white;
}
.k-dropdown {
width: 100%;
}
.k-state-selected.k-state-focused {
background-color: #27AE60;
border: 0;
}
#surveyForm hr {
border: 0;
height: 0;
border-top: 1px solid rgba(0, 0, 0, 0.1);
border-bottom: 1px solid rgba(255, 255, 255, 0.3);
margin-bottom: 10px;
}
/* http://stackoverflow.com/a/17541916/1550052 */
.rad,
.ckb{
cursor: pointer;
user-select: none;
-webkit-user-select: none;
-webkit-touch-callout: none;
padding: 10px;
clear: left;
float: left;
}
.rad > input,
.ckb > input{ /* HIDE ORG RADIO & CHECKBOX */
visibility: hidden;
position: absolute;
}
/* RADIO & CHECKBOX STYLES */
.rad > i,
.ckb > i{ /* DEFAULT <i> STYLE */
display: inline-block;
vertical-align: middle;
width: 16px;
height: 16px;
border-radius: 50%;
transition: 0.2s;
box-shadow: inset 0 0 0 8px #fff;
border: 1px solid #d3d3d3;
background: #666;
margin-right: 4px;
}
/* CHECKBOX OVERWRITE STYLES */
.ckb > i {
width: 25px;
border-radius: 3px;
}
.rad:hover > i{ /* HOVER <i> STYLE */
box-shadow: inset 0 0 0 3px #fff;
background: #666;
}
.rad > input:checked + i{ /* (RADIO CHECKED) <i> STYLE */
box-shadow: inset 0 0 0 3px #fff;
background: #27AE60;
}
/* CHECKBOX */
.ckb > input + i:after{
content: "";
display: block;
height: 12px;
width: 12px;
margin: 2px;
border-radius: inherit;
transition: inherit;
background: #d3d3d3;
}
.ckb > input:checked + i:after{ /* (RADIO CHECKED) <i> STYLE */
margin-left: 11px;
background: #27AE60;
}
<body class='body_S'>
<form id='surveyForm'>
<!-- fieldsets -->
<fieldset >
<h2 class="fs-title">
Demographic Search Criteria for iBE Appointment Scheduler For Your Company Profile
</h2>
<h2 class="fs-subtitle">
The demographic data you select here will be used by planners to help search and identify exhibitors they want to request meetings with. The data you fill in will default on all your booth staff members' profiles, however they can
edit the selections to customize it to what they offer if it differs from what you offer.
</h2>
<h2 class="fs-subtitle">
1
</h2>
<label>Main Type of Business
</label>
<br />
<label class="ckb" for="cb-638-0">
<input type="checkbox" name="cb-638" id="cb-638-0" value="3223" />
<i></i>Accommodations
</label>
<label class="ckb" for="cb-638-1">
<input type="checkbox" name="cb-638" id="cb-638-1" value="3224" />
<i></i>Activities, Attractions & Tours
</label>
<label class="ckb" for="cb-638-2">
<input type="checkbox" name="cb-638" id="cb-638-2" value="3225" />
<i></i>Association
</label>
<label class="ckb" for="cb-638-3">
<input type="checkbox" name="cb-638" id="cb-638-3" value="3226" />
<i></i>Convention and Visitors Bureau
</label>
<label class="ckb" for="cb-638-4">
<input type="checkbox" name="cb-638" id="cb-638-4" value="3227" />
<i></i>Convention Centre
</label>
<label class="ckb" for="cb-638-5">
<input type="checkbox" name="cb-638" id="cb-638-5" value="3228" />
<i></i>Cruise Line
</label>
<label class="ckb" for="cb-638-6">
<input type="checkbox" name="cb-638" id="cb-638-6" value="3229" />
<i></i>Destination Management Company
</label>
<label class="ckb" for="cb-638-7">
<input type="checkbox" name="cb-638" id="cb-638-7" value="3230" />
<i></i>Destination Marketing Organization
</label>
<label class="ckb" for="cb-638-8">
<input type="checkbox" name="cb-638" id="cb-638-8" value="3231" />
<i></i>Event Service Provider
</label>
<label class="ckb" for="cb-638-9">
<input type="checkbox" name="cb-638" id="cb-638-9" value="3232" />
<i></i>Technology Provider
</label>
<label class="ckb" for="cb-638-10">
<input type="checkbox" name="cb-638" id="cb-638-10" value="3233" />
<i></i>Transportation
</label>
<label class="ckb" for="cb-638-11">
<input type="checkbox" name="cb-638" id="cb-638-11" value="3234" />
<i></i>Tourism Board
</label>
<label class="ckb" for="cb-638-12">
<input type="checkbox" name="cb-638" id="cb-638-12" value="3235" />
<i></i>Venues for Meeting/Events (non-hotel)
</label>
</fieldset>
</form>
</body>
</html>
If you want to specifically prevent line breaks within the label element, there is CSS for that:
label.chk, label.rad {
white-space:nowrap;
}
If you want to allow line breaks but not if they would occur between the control and the beginning of the label, you may be able to adjust your code like this:
.nowrap {
white-space:nowrap;
}
<label class="ckb" for="cb-638-1">
<span class="nowrap"><input type="checkbox" name="cb-638" id="cb-638-1" value="3224" />
<i></i>Activities,</span> Attractions & Tours
</label>
(You'll also need to modify the .chk > ... and .rad > ... rules to account for the additional span.)
If you're satisfied with the labels just being columnar, just make label a block level element:
label {
display:block;
}

Custom checkbox using only CSS and HTML

I need to create a custom checkbox using only html and CSS. So far I have:
HTML/CSS:
.checkbox-custom {
opacity: 0;
position: absolute;
}
.checkbox-custom,
.checkbox-custom-label {
display: inline-block;
vertical-align: middle;
margin: 5px;
cursor: pointer;
}
.checkbox-custom + .checkbox-custom-label:before {
content: '';
background: #fff;
border-radius: 5px;
border: 2px solid #ddd;
display: inline-block;
vertical-align: middle;
width: 10px;
height: 10px;
padding: 2px;
margin-right: 10px;
text-align: center;
}
.checkbox-custom:checked + .checkbox-custom-label:before {
content: "";
display: inline-block;
width: 1px;
height: 5px;
border: solid blue;
border-width: 0 3px 3px 0;
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
border-radius: 0px;
margin: 0px 15px 5px 5px;
}
<div>
<input id="checkbox-1" class="checkbox-custom" name="checkbox-1" type="checkbox">
<label for="checkbox-1" class="checkbox-custom-label">First Choice</label>
</div>
<div>
<input id="checkbox-2" class="checkbox-custom" name="checkbox-2" type="checkbox">
<label for="checkbox-2" class="checkbox-custom-label">Second Choice</label>
</div>
The checked checkbox should be a checkmark with the square bordered around it instead of just a checkmark. Searching for answers, I have only found cases where the checkmark is displayed using a UTF-8 character or an image. I am not able to use either of these for what I am trying to accomplish. I am only able to use plain CSS and HTML. Any suggestions?
codepen here: http://codepen.io/alisontague/pen/EPXagW?editors=110
The problem is that you are using the same pseudo element for the square border and the checkmark. The simple solution would be to continue using the :before pseudo element for the border, and then use an :after pseudo element for the checkmark.
Updated Example
You would have to absolutely position the :after pseudo element relative to the parent .checkbox-custom label element.
Here is the updated code:
.checkbox-custom {
display: none;
}
.checkbox-custom-label {
display: inline-block;
position: relative;
vertical-align: middle;
margin: 5px;
cursor: pointer;
}
.checkbox-custom + .checkbox-custom-label:before {
content: '';
background: #fff;
border-radius: 5px;
border: 2px solid #ddd;
display: inline-block;
vertical-align: middle;
width: 10px; height: 10px;
padding: 2px; margin-right: 10px;
}
.checkbox-custom:checked + .checkbox-custom-label:after {
content: "";
padding: 2px;
position: absolute;
width: 1px;
height: 5px;
border: solid blue;
border-width: 0 3px 3px 0;
transform: rotate(45deg);
top: 2px; left: 5px;
}
<h3>Checkboxes</h3>
<div>
<input id="checkbox-1" class="checkbox-custom" name="checkbox-1" type="checkbox">
<label for="checkbox-1" class="checkbox-custom-label">First Choice</label>
</div>
<div>
<input id="checkbox-2" class="checkbox-custom" name="checkbox-2" type="checkbox">
<label for="checkbox-2" class="checkbox-custom-label">Second Choice</label>
</div>
My previous answer is wrong because it uses the ::before pseudo-element selector on an element that isn't a container. Thanks to #BoltClock for pointing out my error. So, I came up with another solution that uses the Checkbox Hack and the CSS3 sibling selector (~).
Demo at CodePen
input[type=checkbox] {
position: absolute;
top: -9999px;
left: -9999px;
}
input[type=checkbox] ~ label::before {
content: '\2713';
display: inline-block;
text-align: center;
color: white;
line-height: 1em;
width: 1em;
height: 1em;
border: 1px inset silver;
border-radius: 0.25em;
margin: 0.25em;
}
input[type=checkbox]:checked ~ label::before {
color: black;
}
<form name="checkbox-form" id="checkbox-form">
<div>
<input id="checkbox-1" class="checkbox-custom" name="checkbox-1" type="checkbox">
<label for="checkbox-1" class="checkbox-custom-label">First Choice</label>
</div>
<div>
<input id="checkbox-2" class="checkbox-custom" name="checkbox-2" type="checkbox">
<label for="checkbox-2" class="checkbox-custom-label">Second Choice</label>
</div>
</form>
I didn't use StackOverflow's "Run Code-Snippet" functionality because it does something weird when I run it. I think it's because of the checkbox hack.
Custom checkbox using only HTML and CSS along with three checkbox states (checked, unchecked and half checked or unchecked(if it's used in a group of checkboxes))
<label class="checkboxcontainer"> one
<input type="checkbox">
<span class="checkmark"></span>
</label>
.checkboxcontainer input {
display: none;
}
.checkboxcontainer {
display: inlin-block;
padding-left: 30px;
position: relative;
cursor: pointer;
user-select: none;
}
.checkboxcontainer .checkmark {
display: inlin-block;
width: 25px;
height: 25px;
background: #eee;
position: absolute;
left: 0;
top: 0;
}
.checkboxcontainer input:checked+.checkmark {
background-color: #2196fc;
}
.checkboxcontainer input:checked+.checkmark:after {
content: "";
position: absolute;
height: 4px;
width: 9px;
border-left: 3px solid white;
border-bottom: 3px solid white;
top: 45%;
left: 50%;
transform: translate(-50%, -50%) rotate(-45deg);
}
.checkboxcontainer input:indeterminate+.checkmark:after {
content: "";
position: absolute;
height: 0px;
width: 9px;
border-left: 3px solid white;
border-bottom: 3px solid white;
top: 45%;
left: 50%;
transform: translate(-50%, -50%) rotate(180deg);
}
Jsfiddle: Demo
.checkbox-custom {
position: relative;
}
.checkbox-custom input[type=checkbox] {
display: none;
}
.checkbox-custom input[type=checkbox]~b {
cursor: pointer;
outline: 0;
position: relative;
display: inline-block;
margin: 4px 1px 0;
background-color: #ffffff;
border: 2px solid #ad823a;
width: 24px;
height: 24px;
vertical-align: middle;
line-height: 1;
text-align: center;
font-size: 20px;
color: #ad823a;
}
.checkbox-custom input[type=checkbox]:checked~b:after {
content: '\2713';
}
<div class="checkbox-custom">
<label>
<input type="checkbox">
<b></b>
<span>app 1</span>
</label>
</div>
<div class="checkbox-custom">
<label>
<input type="checkbox">
<b></b>
<span>app 1</span>
</label>
</div>