How to style span radio buttons with CSS without images - css

I have tried to style these radio buttons with css but i can not figure out why it will not style. I am trying to have a 30px by 30px radio button with a 3px blue border and the inside of the radio button white with a black dot that is the checked one. Any help would be appreciated.
<span class="wpcf7-form-control-wrap RVCategory">
<span class="wpcf7-form-control wpcf7-radio">
<span class="wpcf7-list-item first">
<span class="wpcf7-list-item-label" style="">Motorhome
</span>
<input type="radio" name="RVCategory" value="Motorhome" checked="checked">
</span>
<span class="wpcf7-list-item last">
<span class="wpcf7-list-item-label">Trailer
</span>
<input type="radio" name="RVCategory" value="Trailer">
</span>
</span>
</span>

Hint 1, always include enough code to replicate your problem. Once finding the fiddle it was easily fixed.
Point 1 : Use the label tag and use it corectly. You are using a span where you should be using label. To associate label with a form element use the for attribute with an Id from the form element. It is the label that gives the user something to click on here.
Point 2: Ordering is important with CSS selectors. If your selector is input + label the label tag must come after the input
Point 3: Learn the realtionship with position:releative and position:absolute
Finaly, the solution:
.wpcf7-form-control-wrap.RVCategory {
max-width: 400px;
margin: 94px auto 0 auto;
}
.wpcf7-list-item label {
position: relative;
}
.wpcf7-list-item-label,
.wpcf7-list-item last {
font-size: 20px;
}
.wpcf7-form-control-wrap.RVCategory input[type="radio"] {
position: absolute;
opacity: 0;
-moz-opacity: 0;
-webkit-opacity: 0;
-o-opacity: 0;
}
.wpcf7-form-control-wrap.RVCategory input[type="radio"]+label:before {
content: "";
/*Note inline-block*/
display: inline-block;
top: 2px;
height: 14px;
width: 14px;
background: white;
border: 1px solid gray;
box-shadow: inset 0px 0px 0px 2px white;
-webkit-box-shadow: inset 0px 0px 0px 2px white;
-moz-box-shadow: inset 0px 0px 0px 2px white;
-o-box-shadow: inset 0px 0px 0px 2px white;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
-o-border-radius: 8px;
}
.wpcf7-form-control-wrap.RVCategory input[type="radio"]:checked+label:before {
background: #ef8700;
}
<span class="wpcf7-form-control-wrap RVCategory">
<span class="wpcf7-form-control wpcf7-radio">
<span class="wpcf7-list-item first">
<!-- Note the order had changed
and the addition of an id
-->
<input type="radio" name="RVCategory" value="Motorhome" checked="checked" id="rdoMotorHome">
<!--Note the "for" attribute-->
<label class="wpcf7-list-item-label" style="" for="rdoMotorHome">Motorhome</label>
</span>
<span class="wpcf7-list-item last">
<input type="radio" name="RVCategory" value="Trailer" id="rdoTrailer">
<label class="wpcf7-list-item-label" for="rdoTrailer">Trailer</label>
</span>
</span>
</span>

You can change the size but you can't add a border around a radio button with CSS unless you want a square border - and in that case it would be the element around the button, not styled on the button itself. To change the size of the button, your class needs to go with the input tag. Put your class where the inline style is in the example below.
<input type="radio" name="RVCategory" value="Motorhome" checked="checked" style="width:30px;height:30px;">

Below is the code for your reference, this will help you.
[type="radio"] {
border: 0;
clip: rect(0 0 0 0);
height: 1px; margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
label {
display: block;
cursor: pointer;
line-height: 2;
font-size: 20px;
}
[type="radio"] + span:before {
content: '';
display: inline-block;
width: 15px;
height: 15px;
vertical-align: -0.25em;
border-radius: 10px;
border: 3px solid #fff;
box-shadow: 0 0 0 3px #000;
margin-right: 0.75em;
transition: 0.5s ease all;
}
[type="radio"]:checked + span:before {
background: black;
box-shadow: 0 0 0 0.25em #000;
}
<label for="Motorhome">
<input type="radio" value="Motorhome" name="Test" id="Motorhome"> <span>Motorhome</span>
</label>
<label for="Trailer">
<input type="radio" value="Trailer" name="Test" id="Trailer"> <span>Trailer</span>
</label>

Related

Safari border-color for text input

I have a number of inputs of type text that I have placed a border and border-color around. They show up fine in Chrome, but in Safari the border is the color I selected on two sides and a basic blue on the other two sides. There is no problem with the border of a textfield I have in the same page. But a submit button does not have the correct border color either.
HTML:
<label for="email">Email address</label>
<input type="text" id="email" name="email" />
<label for="telephone">Phone number</label>
<input type="text" id="telephone" name="telephone" />
<label for="notes">Notes</label>
<textarea type="textarea" id="notes" name="notes" /></textarea>
<input type="submit" id="submit" value="Send" />
CSS:
input, textarea, {
display: block;
width: 200px;
height: 20px;
margin: 0 !important;
margin-bottom: 10px !important;
padding: 0 !important;
padding: 4px 8px !important;
font-size: 16px;
background-color: lightgrey;
border-width: 2px !important;
border-radius: 4px;
border-color: #001b43;
outline: none;
}
Searching around, I have found a few related problems and solutions and have tried them, but with no joy. For example:
input.text,
input[type=text],
input[type=email],
input[type=tel],
input[type=url],
input[type=search] {
appearance: none;
-moz-appearance: none;
-webkit-appearance: none;
border-radius: 0;
-moz-border-radius: 0;
-webkit-border-radius: 0;
}
I passed my question on to a friend. He figured it out quickly. The solution is:
border-style: solid;

Size of bootstrap input field

I currently have:
<input name="test" type="text" class="form-control" placeholder="Type here" size="4" maxlength="4">
But the input box still takes up 100% of width.
If I remove the botostrap class form-control then I obviously lose the styling, but the box takes up the 4 character width I intended.
How do I get it to take the width of 4, while also keeping the bootstrap styling?
Its because of .form-control class ,which is bootstrap default class, you have to inherit this class.
for example:-
This is default
.form-control {
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 4px;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
color: #555;
display: block;
font-size: 14px;
height: 34px;
line-height: 1.42857;
padding: 6px 12px;
width: 100%;
}
Use like this:-
<div class="wrap">
<input name="test" type="text" class="form-control" placeholder="Type here" size="4" maxlength="4">
<div>
.wrap .form-control {
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 4px;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
color: #555;
display: block;
font-size: 14px;
height: 34px;
line-height: 1.42857;
padding: 6px 12px;
/*width: 100%;*/ remove this
}
Hope i'll helps you.
You can simple add new class with class="form-control new-input" like below
html
<input type="text" class="form-control new-input">
Css
.new-input{width:100px}
thats it :)
Add a local styling, somehow like:
<input name="test" type="text" class="form-control" placeholder="Type here" style="width:<size value here>" maxlength="4">
HTML:
<div class="form-group">
<input id="test" name="test" type="text" class="form-control" placeholder="Type here">
</div>
CSS:
.form-group #test{
width:50%!important;
}
Example: jsFiddle

Bootstrap 3 tag list with input group

I try to make a tag list (like in stackoverflow) using a bootstrap 3 input group.
The result should look similar to this with a full height button on the right:
The base for my considerations looks like this:
<div class="container-fluid">
<div class="input-group">
<input type="text" class="form-control">
<span class="input-group-btn">
<button class="btn btn-default" type="button">Go!</button>
</span>
</div>
</div>
Here is my attempt to make a tag list out of it (please note that it should have multiple lines)
HTML:
<div class="container-fluid">
<div class="input-group">
<div class="form-control">
<ul>
<li><span class="label label-default">Default</span></li>
<li><span class="label label-primary">Primary</span></li>
<li><span class="label label-success">Success</span></li>
... even more labels ...
<li><span class="label label-default">Default</span></li>
<li><span class="label label-primary">Primary</span></li>
<li><span class="label label-success">Success</span></li>
</ul>
<input type="text">
</div>
<span class="input-group-btn">
<button class="btn btn-default" type="button">Go!</button>
</span>
</div>
</div>
CSS:
ul {
padding-left: 0;
display: inline;
list-style-type: none;
}
li {
display: inline-block;
}
Running demo in fiddle
However, that doesn't work as expected.
To create the tag portion, you can use bootstrap-tagsinput by Tim Schlechter and then style it similar to Bootstrap's Input Group with some custom styling like this:
Demo in jsFiddle & Stack Snippets
.input-group .bootstrap-tagsinput {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
width: 100%
}
.input-group-btn {
height: 0px;
}
.input-group-btn .btn {
height: 100%;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tagsinput/0.8.0/bootstrap-tagsinput.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tagsinput/0.8.0/bootstrap-tagsinput.js"></script>
<div class="input-group">
<input type="text"
class="bootstrap-tagsinput form-control"
data-role="tagsinput"
value="Amsterdam,Washington,Sydney,Beijing,Cairo" />
<span class="input-group-btn">
<button class="btn btn-default" type="button">Go!</button>
</span>
</div>
Dismissable Alert
If you're just trying to style a removable element, you can do that similar to Bootstrap's Dismissable Alert, with some custom styling which will look like this:
Demo in jsFiddle & Stack Snippets:
.alert.alert-tag {
display: inline-block;
padding: 5px;
padding-bottom:2px;
margin: 5px;
}
.alert-tag.alert-dismissible {
padding-right: 25px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.js"></script>
<div class="alert alert-warning alert-dismissible fade in alert-tag" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
Label
</div>
You need edit your item for something like this:
<span class="tag label label-primary">Primary<span data-role=
"remove"></span></span>
Add this to your css:
.bootstrap-tagsinput {
background-color: #fff;
border: 1px solid #ccc;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
display: inline-block;
padding: 4px 6px;
margin-bottom: 10px;
color: #555;
vertical-align: middle;
border-radius: 4px;
max-width: 100%;
line-height: 22px;
cursor: text;
}
.bootstrap-tagsinput input {
border: none;
box-shadow: none;
outline: none;
background-color: transparent;
padding: 0;
margin: 0;
width: auto !important;
max-width: inherit;
}
.bootstrap-tagsinput input:focus {
border: none;
box-shadow: none;
}
.bootstrap-tagsinput .tag {
margin-right: 2px;
color: white;
}
.bootstrap-tagsinput .tag [data-role="remove"] {
margin-left: 8px;
cursor: pointer;
}
.bootstrap-tagsinput .tag [data-role="remove"]:after {
content: "x";
padding: 0px 2px;
}
.bootstrap-tagsinput .tag [data-role="remove"]:hover {
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
}
.bootstrap-tagsinput .tag [data-role="remove"]:hover:active {
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
}
And... add bootstrap-tagsinput to your from-group before ul:
<div class="form-control bootstrap-tagsinput">

Include font awesome inside input type text

I´m trying to include a Font Awesome inside my input in left side but I´m not having sucess. I never used awesome fonts to this purporse. Anyone there knows how to include the font inside the input? Thanks!
The font Im trying to include in left side of my input:
<i class="fa fa-user"></i>
My html:
<form action="" method="post">
<input type="text"class="inputs" placeholder="e-mail" />
<br />
<input type="password" class="inputs"placeholder="Password" />
</form>
My css:
inputs:-webkit-input-placeholder {
color: #b5b5b5;
}
inputs-moz-placeholder {
color: #b5b5b5;
}
.inputs {
background: #f5f5f5;
font-family:"bariol_regularregular", Palatino, serif;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
border: none;
padding: 13px 10px;
width:180px;
margin-bottom: 10px;
box-shadow: inset 0px 2px 3px rgba( 0,0,0,0.1 );
height:20px;
}
.inputs:focus {
background: #fff;
box-shadow: 0px 0px 0px 2px #96842E;
outline: none;
}
This can be achieved with some absolute positioninig. There are two different ways I can think of doing this so I will show you both. Fiddle with both examples here
Method 1
HTML
<label id="email-label">
<input type="text" id="email" placeholder="email here" />
</label>
CSS
#email {
padding-left: 20px;
}
#email-label {
position: relative;
}
#email-label:before {
color: #666;
content:"\f007";
font-family: FontAwesome;
position: absolute;
top: 2px;
left: 5px;
}
Method 2
HTML
<label id="email-label2">
<i class="fa fa-rocket"></i>
<input type="text"id="email2" placeholder="email here" />
</label>
CSS
#email-label2 {
position: relative;
}
#email-label2 .fa-rocket {
color: #666;
top: 2px;
left: 5px;
position: absolute;
}
#email2 {
padding-left: 20px;
}
I purpose this :
HTML
<i class="inside fa fa-user"></i>
<input type="text" class="inp" placeholder="Your account" />
CSS
.inside {
position:absolute;
text-indent:5px;
margin-top:2px;
color:green;
}
.inp {
text-indent:20px;
}
https://jsfiddle.net/ga6j5345/1/

Convert Bootstrap 2.3.2 & jQuery-Spinner to work with Bootstrap 3.*

I am trying to convert xixilive's jQuery Spinner Plugin that uses Bootstrap 2.3.2 code into bootstrap 3.* Unfortunately it's not working as it should be, along with no JavaScript errors, so I believe it's just a CSS issue.
Here is what I have done so far:
HTML/CSS
<div class="input-group spinner" data-trigger="spinner">
<input type="text" value="0"
data-min="0"
data-max="10"
name="spinner"
id="spinner"
data-rule="quantity" readonly />
<span class="input-group-btn">
<!-- Up arrow -->
<a href="javascript:;" class="spin-up" data-spin="up">
<i class="fa fa-sort-up"></i>
</a>
<!-- Down arrow -->
<a href="javascript:;" class="spin-down" data-spin="down">
<i class="fa fa-sort-down"></i>
</a>
</span>
</div>
Expected output
Demo Fiddle: http://jsfiddle.net/DAS3K/
I just solved it by myself. Here is the code if anyone is looking for solution
Replace bootstrap-spinner.css file with this one:
.spinner .input-group-btn {
padding: 2px
}
.spinner .input-group-btn a.spin-up, .spinner .input-group-btn a.spin-down {
height: 10px;
overflow: hidden;
display: block;
text-align: center;
position: relative;
color: #999
}
.spinner .input-group-btn a.spin-up .fa-sort-down, .spinner .input-group-btn a.spin-down .fa-sort-down {
position: relative;
top: -9px
}
.spinner .input-group-btn a.spin-up:hover, .spinner .input-group-btn a.spin-down:hover {
color: #555
}
.spinner input {
width: 4em;
text-align: center;
font-size: 12px;
border-radius: 4px 0 0 4px;
background-color: #FFFFFF;
border: 1px solid #CCCCCC;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
transition: border 0.2s linear 0s, box-shadow 0.2s linear 0s;
line-height: 20px;
}
.spinner .input-group-btn {
background-color: #EEEEEE;
border: 1px solid #CCCCCC;
height: 20px;
line-height: 20px;
min-width: 14px;
padding: 4px 5px;
text-align: center;
text-shadow: 0 1px 0 #FFFFFF;
width: auto;
}
.spinner .input-group-btn a:focus {color: #999 !important; }
and use following HTML code
<div class="col-sm-1">
<div class="input-group spinner" data-trigger="spinner">
<input type="text" class="form-control" value="0" data-min="0" data-max="10" name="spinner" id="spinner" data-rule="quantity" >
<span class="input-group-btn">
<i class="fa fa-sort-desc"></i>
<i class="fa fa-sort-down"></i>
</span>
</div>
</div>
If you use to want use glyphicon instead of font-awesome then replace fa and fa-xxx classes in HTML and bootstrap.spinner.css file as well.
You could:
Wrap the buttons into a bootstrap add-on
Switch icon to glyphicon for the icon spinners, there's no direct suitable change though for the old to new icons thus I've adjusted for chevrons.
Swap input-group-btn to input-group-addon
This would produce HTML a little like:
<div class="input-append spinner" data-trigger="spinner">
<div class="input-group">
<input type="text" id="spinner-input" class="form-control" value="1" data-rule="quantity" />
<span class="input-group-addon">
<i class="glyphicon glyphicon-chevron-up"></i>
<br />
<i class="glyphicon glyphicon-chevron-down"></i>
</span>
</div>
</div>
I've had apply some extra CSS rules and the linebreak for the buttons could be handled instead with mini columns instead! but I hope that gives you an head-start regardless!
Result:
Demo Fiddle: http://jsfiddle.net/792hq/

Resources