How to properly style checkbox with letter in it.
Here is the code what I have done but due to similar IDs the style in it was not working.
The First checkbox working as expected but the second not working.
Also I want when the check box clicked the Text in it will invisible.
Can we use class based so that it can be reused ?
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
body {
margin: 10px;
}
.roundchk {
position: relative;
}
.roundchk label {
background-color: #fff;
border: 1px solid #ccc;
border-radius: 50%;
cursor: pointer;
height: 28px;
left: 0;
position: absolute;
top: 0;
width: 28px;
font-size: 16px;
padding: 3px 0px 2px 5px;
}
.roundchk label:after {
border: 2px solid #fff;
border-top: none;
border-right: none;
content: "";
height: 6px;
left: 7px;
opacity: 0;
position: absolute;
top: 8px;
transform: rotate(-45deg);
width: 12px;
}
.roundchk input[type="checkbox"] {
visibility: hidden;
}
.roundchk input[type="checkbox"]:checked + label {
background-color: #66bb6a;
border-color: #66bb6a;
}
.roundchk input[type="checkbox"]:checked + label:after {
opacity: 1;
}
<div class="container">
<div class="row">
<form class="form-horizontal">
<!-- Text input-->
<div class="container">
<h2>
Select Weekdays
</h2>
<table width="100%" border="0">
<tr>
<td>
<div class="roundchk">
<input name="Sunday" type="checkbox" id="checkbox" value="Sun"/>
<label for="checkbox"> S </label>
</div>
</td>
<td>
<div class="roundchk">
<input name="Monday" type="checkbox" id="checkbox" value="Monday"/>
<label for="checkbox"> M </label>
</div>
</td>
<td>
<div class="roundchk">
<input name="Tues" type="checkbox" id="checkbox" value="Tues"/>
<label for="checkbox"> T </label>
</div>
</td>
<td>
<div class="roundchk">
<input name="Wed" type="checkbox" id="checkbox" value="Wed"/>
<label for="checkbox"> W </label>
</div>
</td>
<td>
<div class="roundchk">
<input name="Thurs" type="checkbox" id="checkbox" value="Thurs"/>
<label for="checkbox"> T </label>
</div>
</td>
<td>
<div class="roundchk">
<input type="checkbox" id="checkbox-Fri" name="Fri"/>
<label for="checkbox"> F </label>
</div>
</td>
<td>
<div class="roundchk">
<input type="checkbox" id="checkbox-sat" name="Sat" />
<label for="checkbox"> S </label>
</div>
</td>
</tr>
</table>
</div>
</form>
</div>
</div>
The id of a labelable form-related element in the same document as the element. The first element in the document with an id matching the value of the for attribute is the labeled control for this label element, if it is a labelable element. If it is not labelable then the for attribute has no effect. If there are other elements which also match the id value, later in the document, they are not considered.
read label - MDN's for attribute
Try this,
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
body {
margin: 10px;
}
.roundchk {
position: relative;
}
.roundchk label {
background-color: #fff;
border: 1px solid #ccc;
border-radius: 50%;
cursor: pointer;
height: 28px;
left: 0;
position: absolute;
top: 0;
width: 28px;
font-size: 16px;
padding: 3px 0px 2px 5px;
}
.roundchk label:after {
border: 2px solid #fff;
border-top: none;
border-right: none;
content: "";
height: 6px;
left: 7px;
opacity: 0;
position: absolute;
top: 8px;
transform: rotate(-45deg);
width: 12px;
}
.roundchk input[type="checkbox"] {
visibility: hidden;
}
.roundchk input[type="checkbox"]:checked + label {
background-color: #66bb6a;
border-color: #66bb6a;
}
.roundchk input[type="checkbox"]:checked + label:after {
opacity: 1;
}
<div class="container">
<div class="row">
<form class="form-horizontal">
<!-- Text input-->
<div class="container">
<h2>
Select Weekdays
</h2>
<table width="100%" border="0">
<tr>
<td>
<div class="roundchk">
<input name="Sunday" type="checkbox" id="checkbox-sun" value="Sun"/>
<label for="checkbox-sun"> S </label>
</div>
</td>
<td>
<div class="roundchk">
<input name="Monday" type="checkbox" id="checkbox-mon" value="Monday"/>
<label for="checkbox-mon"> M </label>
</div>
</td>
<td>
<div class="roundchk">
<input name="Tues" type="checkbox" id="checkbox-tue" value="Tues"/>
<label for="checkbox-tue"> T </label>
</div>
</td>
<td>
<div class="roundchk">
<input name="Wed" type="checkbox" id="checkbox-wed" value="Wed"/>
<label for="checkbox-wed"> W </label>
</div>
</td>
<td>
<div class="roundchk">
<input name="Thurs" type="checkbox" id="checkbox-thrus" value="Thurs"/>
<label for="checkbox-thrus"> T </label>
</div>
</td>
<td>
<div class="roundchk">
<input type="checkbox" id="checkbox-fri" name="Fri"/>
<label for="checkbox-fri"> F </label>
</div>
</td>
<td>
<div class="roundchk">
<input type="checkbox" id="checkbox-sat" name="Sat" />
<label for="checkbox-sat"> S </label>
</div>
</td>
</tr>
</table>
</div>
</form>
</div>
</div>
Related
I have certain field as a table data which i converted from psd to html.
The image is shown below ..
Part of html code is ...
<tr>
<td colspan="13">
<img src="images/WebDesign_32.png" width="1200" height="24" alt="" class="texxt"></td>
<td>
<img src="images/spacer.gif" width="1" height="24" alt=""></td>
</tr>
<tr>
How to get text from top of this src="images/WebDesign_32.png" text using a form.
Try this code
.form-wrapper {
width: 400px;
display:block;
margin: 0 auto;
}
.form-wrapper .form-field {
width: 100%;
display: block;
margin-bottom: 15px;
}
.form-wrapper .form-field label {
display: block;
float: left;
min-width: 100px;
font-weight: bold;
}
.form-wrapper .form-field input,
.form-wrapper .form-field email,
.form-wrapper .form-field textarea {
width: 200px;
background: #c9cdd7;
border: none;
line-height: 20px;
margin-left: 20px;
resize: none;
}
.form-wrapper .form-field .submit-btn {
width:100px;
float:right;
background: #1949cb;
font-weight: bold;
}
<div class="form-wrapper">
<form>
<div class="form-field">
<label for="name">Name</label>
<input type="text" />
</div>
<div class="form-field">
<label for="email">Email</label>
<input type="email" />
</div>
<div class="form-field">
<label for="telephone">Telephone</label>
<input type="text" />
</div>
<div class="form-field">
<label for="message">Message</label>
<textarea></textarea>
</div>
<div class="form-field">
<input type="submit" class="submit-btn">
</div>
</form>
</div>
I am trying to design a vertical stepper with content in the right side. However, I am having a problem. The problem is the distance between the steps are not constant when i have the content. Because the steps distance are taken based on the height of content. How can i overcome this issue and make the distance between each step constant no matter how the long the content is ?
Here is what i have done for now
.container {
width: 100%;
background: #fff;
}
.step {
padding: 50px 10px;
display: flex;
flex-direction: row;
justify-content: flex-start;
}
.v-stepper {
position: relative;
}
.step .circle {
background-color: #dedede;
border-radius: 100%;
width: 24px;
height: 24px;
display: inline-block;
}
.step .line {
top: 24px;
left: 12px;
height: 100%;
position: absolute;
border-left: 1px solid #dedede;
}
.step.completed .circle {
visibility: visible;
background-color: rgb(6, 150, 215);
border-color: rgb(6, 150, 215);
}
.step.completed .label {
color: rgb(6, 150, 215);
}
.step.active .circle {
visibility: visible;
border-color: rgb(6, 150, 215);
}
.step.empty .circle {
visibility: hidden;
}
.step.empty .line {
top: 0;
height: 150%;
}
.step:last-child .line {
display: none;
}
.label {
margin-left: 20px;
display: inline-block;
}
.headline {
background: #dedede;
padding: 5px;
}
<div class="container">
<div class="step completed">
<div class="v-stepper">
<div class="circle"></div>
<div class="line"></div>
</div>
<div class="label">
Personal
</div>
<div class="content">
<h3>Personal</h3>
<p>Description on the topic personal</p>
<h3 class="headline">Information</h3>
<form>
<input type="text" id="first_name" />
<input type="text" id="last_name" />
<input type="text" id="Phone Number" />
<input type="text" id="email" />
<input type="text" id="address" />
<input type="text" id="country" />
<input type="text" id="city" />
</form>
</div>
</div>
<div class="step">
<div class="v-stepper">
<div class="circle"></div>
<div class="line"></div>
</div>
<div class="label">
Education
</div>
</div>
<div class="step">
<div class="v-stepper">
<div class="circle"></div>
<div class="line"></div>
</div>
<div class="label">
Background
</div>
</div>
</div>
UPDATE
I mean the following way
the stepper should have constant height(the distance from one circle to another) no matter how long it's respective content has. Because I will only be showing the content of selected step.
As the second comment by godfather suggested, to make circles connected to each other remove the padding top and bottom from .step and to keep the content of each step has its own padding just add padding to .step .content.
Here's a working snippet
.container {
width: 100%;
background: #fff;
}
.step {
/* Remove the padding from top and bottom*/
/*padding: 50px 10px;*/
padding: 0 10px;
display: flex;
flex-direction: row;
justify-content: flex-start;
position: relative;
}
/* Add this to make the content of each step has its own padding */
.step .content{
padding: 20px 0 50px;
}
.v-stepper {
position: relative;
}
.step .circle {
background-color: #dedede;
border-radius: 100%;
width: 24px;
height: 24px;
display: inline-block;
}
.step .line {
top: 24px;
left: 12px;
height: 100%;
position: absolute;
border-left: 1px solid #dedede;
}
.step.completed .circle {
visibility: visible;
background-color: rgb(6, 150, 215);
border-color: rgb(6, 150, 215);
}
.step.completed .label {
color: rgb(6, 150, 215);
}
.step.active .circle {
visibility: visible;
border-color: rgb(6, 150, 215);
}
.step.empty .circle {
visibility: hidden;
}
.step.empty .line {
top: 0;
height: 150%;
}
.step:last-child .line {
display: none;
}
.label {
margin-left: 20px;
display: inline-block;
}
.headline {
background: #dedede;
padding: 5px;
}
<div class="container">
<div class="step completed">
<div class="v-stepper">
<div class="circle"></div>
<div class="line"></div>
</div>
<div class="label">
Personal
</div>
<div class="content">
<h3>Personal</h3>
<p>Description on the topic personal</p>
<h3 class="headline">Information</h3>
<form>
<input type="text" id="first_name" />
<input type="text" id="last_name" />
<input type="text" id="Phone Number" />
<input type="text" id="email" />
<input type="text" id="address" />
<input type="text" id="country" />
<input type="text" id="city" />
</form>
</div>
</div>
<div class="step">
<div class="v-stepper">
<div class="circle"></div>
<div class="line"></div>
</div>
<div class="label">
Education
</div>
<div class="content">
<h3>Personal</h3>
<p>Description on the topic personal</p>
<h3 class="headline">Information</h3>
<form>
<input type="text" id="first_name" />
<input type="text" id="last_name" />
<input type="text" id="Phone Number" />
<input type="text" id="email" />
<input type="text" id="address" />
<input type="text" id="country" />
<input type="text" id="city" />
</form>
</div>
</div>
<div class="step">
<div class="v-stepper">
<div class="circle"></div>
<div class="line"></div>
</div>
<div class="label">
Background
</div>
</div>
</div>
I'm attempting to create a similar UI as below using radio inputs. Most of the UI was fairly easy to recreate, the only exception is adding the arrow (icon?) to the end of the label div. I've attempted to div an arrow in and force it to the center using margins, but it's obviously not a very good solution. What's the best way to add the arrow at the end of the label?
Here's the current code
<div id='results'>
<form>
<input type="radio" name="result" value="1" id='opt-1' checked>
<label for="opt-1"><h3>Option 1</h3>
<p>Short Description of Option 1</p></label><br>
<input type="radio" name="result" value="2" id='opt-2' checked>
<label for="opt-2"><h3>Option 2</h3>
<p>Short Description of Option 2</p></label><br>
<input type="radio" name="result" value="3" id='opt-3' checked>
<label for="opt-3"><h3>Option 3</h3>
<p>Short Description of Option 3</p></label><br>
</form>
</div>
JSFiddle
EDIT:
I'm aware the JSFiddle doesn't apply the background correctly. The code does operate fine on production.
I've created a wrapper of class .list for each radio item to bind the data.
<div id='results'>
<form>
<div class="list">
<span>
<input type="radio" name="result" value="1" id='opt-1' checked>
</span>
<span class="radio-content">
<span>
<label class="mb-1" for="opt-1"><h3>Option 1</h3>
<p class="d-inline">Short Description of Option 1</p></label><br>
</span>
<span class="arrow"><</span>
</span>
</div>
<div class="list">
<span>
<input type="radio" name="result" value="1" id='opt-1' checked>
</span>
<span class="radio-content">
<span>
<label class="mb-1" for="opt-1"><h3>Option2</h3>
<p class="d-inline">Short Description of Option 2</p></label><br>
</span>
<span class="arrow"><</span>
</span>
</div>
</form>
</div>
CSS code here
.list{
display: flex;
align-items:center;
}
.mb-1{
margin-bottom: 8px;
}
.radio-content{
width:100%;
display:flex;
align-items:center;
justify-content: space-between;
}
Instead of "<" you can use the appropriate icon with the appropriate spacing
label {
background-color: #16a085;
background: linear-gradient(to right, #16a085, #66a99c);
width: 80%;
padding-left: 15px;
padding-top: 10px;
margin-bottom: 3px;
}
form > label > h3 {
margin-bottom: 1px;
}
form > label > p {
margin-top: 1px;
}
form > label h3::after {
content: '\276E';
position: absolute;
right: 0;
padding-right: 20px;
}
input[type=radio] {
display: none;
}
<div id='results'>
<form>
<input type="radio" name="result" value="1" id='opt-1' checked>
<label for="opt-1">
<h3>Option 1</h3>
<p>Short Description of Option 1</p>
</label><br>
<input type="radio" name="result" value="2" id='opt-2' checked>
<label for="opt-2">
<h3>Option 2</h3>
<p>Short Description of Option 2</p>
</label><br>
<input type="radio" name="result" value="3" id='opt-3' checked>
<label for="opt-3">
<h3>Option 3</h3>
<p>Short Description of Option 3</p>
</label><br>
</form>
</div>
So flexbox is awesome for layouts like these. It performs well and has great browser support (http://caniuse.com/#search=flexbox). IE has some issues but should be able to work around.
ul {
list-style: none;
width: 400px;
border: 1px solid #ccc;
margin: 0;
padding: 0;
}
ul li {
display: flex;
flex-direction: row;
justify-content: space-between;
border-bottom: 1px solid #ccc;
}
ul li:last-child {
border-bottom: none;
}
.title {
flex-grow: 1;
padding-top: 4px;
}
.title h3 {
margin: 0;
}
.title p {
font-size: 9px;
color: #aaa;
margin: 1px 0 0 0;
}
.icon {
padding-left: 10px;
width: 40px;
line-height: 50px;
display: inline-block;
}
.toggle-switch {
line-height: 50px;
width: 50px;
display: inline-block;
text-align: center;
}
<ul>
<li>
<span class="icon">*</span>
<div class="title">
<h3>Stops</h3>
<p>Non stop, 1 stop, 2+ stops</p>
</div>
<span class="toggle-switch">^</span>
</li>
<li>
<span class="icon">*</span>
<div class="title">
<h3>Duration</h3>
<p>Any</p>
</div>
<span class="toggle-switch">^</span>
</li>
</ul>
I grabbed a simple tab control from the css tricks site and its working great for me, except when I have two tab controls on the same page, clicking the bottom control simply changes the tab page of the top control.
The CSS Tricks page with the original code is here
Changing the name= attribute for the second group doesn't fix it.
Renaming the id's of each tab in the second group also doesn't fit it.
Is there a way to have two independently operating tabs on the same page ?
FWIW the HTML and CSS are fairly simple:
.tabs {
position: relative;
min-height: 100px;
clear: both;
margin: 25px 0;
}
.tabs .tab {
float: left;
}
.tabs .tab label {
background: #eee;
padding: 5px 15px 5px 15px;
border: 1px solid #ccc;
position: relative;
left: 1px;
cursor: pointer;
}
.tabs .tab [type=radio] {
display: none;
}
.tabs .content {
position: absolute;
top: 18px;
left: 0;
background: white;
right: 0;
bottom: 0;
padding: 20px;
border: 1px solid #ccc;
overflow:auto;
}
.tabs [type=radio]:checked ~ label {
background: white;
border-bottom: 1px solid white;
z-index: 2;
}
.tabs [type=radio]:checked ~ label ~ .content {
z-index: 1;
}
<div class="tabs">
<div class="tab">
<input type="radio" id="tab-1" name="tab-group-1" checked>
<label for="tab-1">Tab One</label>
<div class="content">
stuff1
</div>
</div>
<div class="tab">
<input type="radio" id="tab-2" name="tab-group-1">
<label for="tab-2">Tab Two</label>
<div class="content">
stuff2
</div>
</div>
<div class="tab">
<input type="radio" id="tab-3" name="tab-group-1">
<label for="tab-3">Tab Three</label>
<div class="content">
stuff3
</div>
</div>
</div>
<div class="tabs">
<div class="tab">
<input type="radio" id="tab-1" name="tab-group-1" checked>
<label for="tab-1">Tab One</label>
<div class="content">
stuff4
</div>
</div>
<div class="tab">
<input type="radio" id="tab-2" name="tab-group-1">
<label for="tab-2">Tab Two</label>
<div class="content">
stuff5
</div>
</div>
<div class="tab">
<input type="radio" id="tab-3" name="tab-group-1">
<label for="tab-3">Tab Three</label>
<div class="content">
stuff6
</div>
</div>
</div>
The part to change is the label and the id:
<input type="radio" id="tab-1" name="tab-group-1" checked>
<label for="tab-1">Tab One</label>
I've edited your snippet.
.tabs {
position: relative;
min-height: 100px;
clear: both;
margin: 25px 0;
}
.tabs .tab {
float: left;
}
.tabs .tab label {
background: #eee;
padding: 5px 15px 5px 15px;
border: 1px solid #ccc;
position: relative;
left: 1px;
cursor: pointer;
}
.tabs .tab [type=radio] {
display: none;
}
.tabs .content {
position: absolute;
top: 18px;
left: 0;
background: white;
right: 0;
bottom: 0;
padding: 20px;
border: 1px solid #ccc;
overflow:auto;
}
.tabs [type=radio]:checked ~ label {
background: white;
border-bottom: 1px solid white;
z-index: 2;
}
.tabs [type=radio]:checked ~ label ~ .content {
z-index: 1;
}
<div class="tabs">
<div class="tab">
<input type="radio" id="tab-1" name="tab-group-1" checked>
<label for="tab-1">Tab One</label>
<div class="content">
stuff1
</div>
</div>
<div class="tab">
<input type="radio" id="tab-2" name="tab-group-1">
<label for="tab-2">Tab Two</label>
<div class="content">
stuff2
</div>
</div>
<div class="tab">
<input type="radio" id="tab-3" name="tab-group-1">
<label for="tab-3">Tab Three</label>
<div class="content">
stuff3
</div>
</div>
</div>
<div class="tabs">
<div class="tab">
<input type="radio" id="tab-4" name="tab-group-1" checked>
<label for="tab-4">Tab One</label>
<div class="content">
stuff4
</div>
</div>
<div class="tab">
<input type="radio" id="tab-5" name="tab-group-1">
<label for="tab-5">Tab Two</label>
<div class="content">
stuff5
</div>
</div>
<div class="tab">
<input type="radio" id="tab-6" name="tab-group-1">
<label for="tab-6">Tab Three</label>
<div class="content">
stuff6
</div>
</div>
</div>
.selected_area {
background-color: #c8c8c8;
padding-top:5px;
height: 330px;
border-radius: 5px;
width:233px;
}
<div class="selected_area">
<label>
<input type="checkbox" value="scooter" id=""><div class="label-text fa-lg"><span>ScooterScooterScooterScooterScooter ScooterScooterScooter cooterScooterScooterScooter ScooterScooterScooter</span></div>
</label>
<label>
<input type="checkbox" value="motorcycle" id=""><div class="label-text fa-lg"><span>Motorcycle</span></div>
</label>
<label>
<input type="checkbox" value="downtown 250 en" id=""><div class="label-text fa-lg"><span>DOWNTOWN 250(EN)DOWNTOWN 250(EN)DOWNTOWN 250(EN) DOWNTOWN 250(EN)DOWNTOWN 250(EN)</span></div>
</label>
</div>
How to make my text next to checkbox not under it?
For this you've to write CSS like:
input[type="checkbox"] {
display: inline-block;
width: 15px;
vertical-align: top;
}
.label-text {
display: inline-block;
width: 200px;
word-break: break-all;
}
Also for side-by-side alignment you should use <span> instead of block elements like <div>.
I've created JSFiddle, please have a look.
try this
<div class="selected_area">
<label>
<input type="checkbox" value="scooter" id="">
<span class="label-text fa-lg">
<span>ScooterScooterScooterScooterScooter ScooterScooterScooter cooterScooterScooterScooter ScooterScooterScooter</span>
</span>
<br>
</label>
<label>
<input type="checkbox" value="motorcycle" id="">
Motorcycle
<br>
</label>
<label>
<input type="checkbox" value="downtown 250 en" id="">
DOWNTOWN 250(EN)DOWNTOWN 250(EN)DOWNTOWN 250(EN) DOWNTOWN 250(EN)DOWNTOWN 250(EN)
</label>
</div>
maybe so?
* {
padding: 0;
margin: 0;
}
.selected_area {
background-color: #c8c8c8;
padding:10px;
height: 330px;
border-radius: 5px;
width:233px;
margin: 20px;
}
.selected_area label {
position: relative;
margin: 10px 0;
display: block;
}
.selected_area .label-text {
position: relative;
padding-left: 24px;
}
.selected_area input {
position: absolute;
top: 2px;
left: 0;
}
<div class="selected_area">
<label>
<input type="checkbox" value="scooter" id="">
<div class="label-text fa-lg"><span>ScooterScooterScooterScooter ScooterScooterScooter cooterScooterScooterScooter ScooterScooterScooter</span>
</div>
</label>
<label>
<input type="checkbox" value="motorcycle" id="">
<div class="label-text fa-lg"><span>Motorcycle</span>
</div>
</label>
<label>
<input type="checkbox" value="downtown 250 en" id="">
<div class="label-text fa-lg"><span>DOWNTOWN 250(EN)DOWNTOWN 250(EN)DOWNTOWN 250(EN) DOWNTOWN 250(EN)DOWNTOWN 250(EN)</span>
</div>
</label>
</div>
.label-text.fa-lg {
display: inline-block;
}
check this link for more help on display property
https://css-tricks.com/almanac/properties/d/display/