CSS- Coloured cox inside form field - css

I am a newbie but pretty good at CSS, But i can not seem to get my head around doing the following:
It is the box and background, that is confusing me. The rest i am perfecting fine with. Any pointers would be very helpful. I know bootstrap have a similar plugin, but i find bootstrap a nightmare to use.
I have tired countless of ridiculous things, i am to embarrassed to show, thought is is about time i ask the pro's.
input[type=text]{
background-color: linear-gradient(90deg, #FFC0CB 50%, #00FFFF 50%);
color: black;
}
input[type=text]{
background-color: red;
color: aqua;
background-size: 20%;
}
HTML
<div id="section_left">
<form id="franchiseDets" action ="Franchise-Details.php" method="POST">
<!-- franchise details form-->
<div class="field">
<input type="text" name="fran_name" id="fran_name" value="<?php echo $_SESSION['fran_name']; ?>" placeholder="e.g One Delivery Leeds" pattern="[a-zA-Z]"
autofocus required tabindex="1">
<br>
<input type="email" name="fran_email" id="fran_email" value="<?php echo $_SESSION['fran_email'] ?> ' <?php echo $disabled ?>" placeholder="leeds#one-delivery.co.uk" required tabindex="2">
<br>
<input type="text" name="mang_name" id="mang_name" value="<?php echo $_SESSION['mang_name']; ?>" placeholder="Joe Blogs" required tabindex="3">
<br>
These are last two ridiculous things i have tired

Here is a method I would usually use.
Pure CSS and semantics :)
HTML
<fieldset class="example">
<input type="text" placeholder="Phone" />
</fieldset>
CSS
fieldset.example {
position: relative;
}
fieldset.example,
fieldset.example:before,
fieldset.example input {
height: 33px;
padding: 0;
border-width: 0;
/* remove default border */
}
fieldset.example input {
border: 1px solid red;
border-left: 0px;
padding-left: 5px;
border-radius: 0 5px 5px 0;
}
fieldset.example:before {
content: "\0260E";
width: 30px;
border: 1px solid red;
display: inline-block;
float: left;
position: relative;
background: red;
color: white;
text-align: center;
line-height: 33px;
border-radius: 5px 0 0 5px;
}
LIVE EXAMPLE
http://codepen.io/KarlDoyle/pen/grRrwG

This is how I would have solved it with less code as comment suggested:
(Do not evauluate the design)
.input-field {
/* And border and so on... */
background-color: #f00;
box-sizing: border-box;
padding-left: 2em;
position: relative;
}
.input-field:before {
content: "X"; /* Use this if the icon comes from a font,
or relpace it with a space and then use the background-image property */
position: absolute;
left: 0;
width: 2em; /* Just to center the padding */
text-align: center;
font-size: 1em; /* For the scalability */
}
.input-field > input {
width: 100%;
font-size: 1em;
}
/* This is just for play, to test the scaleability */
.fill-row {
width: 100%;
}
.big {
font-size: 2em;
}
.short {
max-width: 160px;
}
<div class="input-field fill-row">
<input />
</div>
<div class="input-field big short">
<input />
</div>
<div class="input-field short">
<input />
</div>

Related

HTML/CSS How do I make the display responsive for smaller screens by stacking this as a column?

I was experimenting with building a basic chat room system with HTML and I ran into some issues when attempting to implement responsive design for small-screen platforms. I've tried and tried for hours with all sorts of different solutions but am unfortunately still stuck. :(
I should just say, I'm an extremely inexperienced programmer in this area I should warn you the code is messy.
I've attached an image of the basic display on the wide screen of my PC.
Images:
Small-screen attempt at display and
Basic large-screen attempt at display
I have also attached an image of what happens when I try to shrink it - namely, half of it goes off screen and the other half is only accessible through scrolling.
Here's the code:
<!DOCTYPE html>
<html>
<head>
<title>
Grav1ty: Login
</title>
<link rel="stylesheet" href="gravitystyle.css">
<meta charset="UTF-8">
<meta name="description" content="Grav1ty Chat">
<meta name="keywords" content="Grav1ty, grud, soyuznerushimy, grav1ty">
<meta name="author" content="Grud">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="gravitylogo.PNG" />
</head>
<body style="background-image:url('background.jpg');font-family:Courier New;">
<div class="exampleheader">
<img src="gravitylogo.PNG" alt="Grav1ty Logo">
<p style ="color:white;"><font size="7">Grav1ty</font><p>
</div>
<!--<div class="examplerow">-->
<div class="exampleheadera" class="container" style="padding: 10px; border: none;">
<!--<div class="loginlayout">-->
<div>
<p style="color:#66c3fe;">
<fieldset class="fieldseta" style="color:#66c3fe; padding: 10px; height: 350px; width: 300px;">
<legend><b><h3>Welcome!</h3></b></legend>
Welcome to <b>Grav1ty</b>,<br>Grav1ty is a <b>FREE</b>, online messaging service free from interruption or surveillance that will be developed over the next few months to suit your needs. Any queries? Contact me through Grav1ty! My username's Grud (well duh) and I'll be happy to help you out. Feel free to chat as you see fit...<br><br><i>Grud</i><br><br><b>Current Status: ONLINE</b>
</fieldset>
</div>
<div>
<form style ="color:white;" action="login.php">
<fieldset class="fieldsetb" style="color:#66c3fe; height: 325px; padding: 30px;">
<legend><b><h3>Log in:</h3></b></legend>
Username:
<input type="text" name="username" placeholder="Username" required><br>
<br>Password:
<input type="password" name="password" placeholder="Password" required>
<br>
<br>
<input type="submit" value="SUBMIT" class="buttona">
</form>
</fieldset>
</form>
</div>
<div>
<form style ="color:white;">
<fieldset class="fieldsetc" style="color:#66c3fe; height: 325px; padding: 30px;">
<legend><b><h3>Sign Up:</h3></b></legend>
Name:
<input type="text" name="newname" placeholder="Name" required><br>
<br>Username:
<input type="text" name="newusername" placeholder="Username" required><br>
<br>Password:
<input type="password" name="newpassword" placeholder="Password" required>
<br>
<br>
<input type="submit" value="SUBMIT" class="buttona">
</form>
</p>
</fieldset>
</form>
<!--</div>-->
</div>
</div>
<!--</div>-->
</body>
</html>
And here's the CSS stylesheet:
.buttona {
background-color: #657EEB;
border: 2px solid #1C43EF;
border-radius: 6px;
color: white;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 14px;
margin: 4px 2px;
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.4s;
}
.buttona:hover {
color: blue;
background-color: white
}
.exampleheader {
padding: 10px;
text-align: center;
background: #9b9ce7;
color: #11f2f2;
border-radius: 2px;
display: flex;
}
.exampleheadera {
padding: 10px;
text-align: center;
background: white;
color: #11f2f2;
border-radius: 2px;
display: flex;
flex-direction: row;
justify-content: center;
}
.examplenavbar {
display: flex;
background-color: #333;
justify-content: space-around;
}
.examplenavbar a {
color: white;
padding: 14px 20px;
text-decoration: none;
text-align: center;
}
.examplenavbar a:hover {
background-color: #ddd;
color: black;
}
.examplerow {
display: flex;
flex-wrap: wrap;
}
/* Create two unequal columns that sits next to each other */
/* Sidebar/left column */
.exampleside {
flex: 30%;
background-color: #f1f1f1;
padding: 20px;
}
/* Main column */
.examplemain {
flex: 70%;
background-color: white;
padding: 20px;
}
/* Fake image, just for this example */
.examplefakeimg {
background-color: #aaa;
width: 100%;
padding: 20px;
}
/* Footer */
.examplefooter {
padding: 20px;
text-align: center;
background: #ddd;
}
/* Responsive layout - when the screen is less than 700px wide, make the two columns stack on top of each other instead of next to each other */
.fieldseta {
display: block;
padding-left: 3px;
padding-right: 3px;
border: 2px solid #b4fef5 ;
background-color: white;
height: 550px
}
.fieldsetb {
display: block;
padding-left: 3px;
padding-right: 3px;
border: 2px solid #b4fef5 ;
background-color: white;
height: 550px
}
.fieldsetc {
display: block;
padding-left: 3px;
padding-right: 3px;
border: 2px solid #b4fef5 ;
background-color: white;
height: 550px
}
.loginlayout {
display: flex;
justify-content: space-between;
border: 3px solid #b4fef5;
padding: 30px;
}
Something like this?
https://codebrace.com/editor/b1d87528b
Here in the example, I have added following property
display: inline-block;
vertical-align: top;
to each and every child div (.contsidebyside) inside .exampleheadera.
and removed
display: flex;
from .exampleheadera
Hope this Helps! :)

Use an image instead of a Bootstrap's glyphicon

I would like to use a custom image in an input-group instead of a Bootstrap glyphicon without padding bottom (my image touch the bottom of the button), as you can see on this picture:
Actually, I use Bootstrap's glyphicon glyphicon-search:
<div class="input-group">
<input type="text" class="form-control" placeholder="Rechercher un produit, une référence ..."/>
<span class="input-group-addon">
<span aria-hidden="true" class="glyphicon glyphicon-search"></span>
<span class="hidden-xs text-upper-style">
Rechercher</span>
</span>
</div>
My issue is that I fail to replace glyphicon by my picture in my search bar.
I've tried to create CSS to mimic those of Bootstrap, but it always render bad:
CSS
.glyphi {
position: relative;
top: 1px;
display: inline-block;
font-style: normal;
font-weight: normal;
line-height: 1;
float: left;
display: block;
}
.glyphi.search {
background: url(../img/header/search.png);
background-size: cover;
}
.glyphi.normal {
width: 28px; //But Bootstrap glyphicon is 16x16...
height: 16px;
}
HTML
<span class="glyphicon glyphicon-search"></span>
Note that my image is not square (60x37 px).
Here is the picture that should replace the glyphicon:
What is the best Bootstrap way to do that?
Here is a Bootply of my code.
Thanks! :)
You can use simple img inside .input-group-addon instead of span.glyphicon and with some negative margins you can get the result you want.
HTML
<div class="input-group">
<input type="text" class="form-control" placeholder="Rechercher un produit, une référence ...">
<span class="input-group-addon">
<img src="http://i.stack.imgur.com/vr0uy.png">
<span class="hidden-xs text-upper-style">Rechercher</span>
</span>
</div>
CSS
.rechercheProduit .input-group-addon img{
height: 24px;
margin-right: -16px;
margin-bottom: -6px;
vertical-align:text-bottom; /* align the text */
}
Updated Bootply
You should have a look on how the glyphicon span works:
If you inspect it, you will see that the interesting part in this span is actually its pseudo-element, the :before that calls a font of icons as a content.
A few solutions are actually possible to resolve your problem.
Override
One of the solution would be to override that pseudo element by
redeclaring its content:
.rechercheProduit .input-group-addon {
/* Declaring the parent as relative so the .glyphicon-search child span
as a position absolute to its parent..
That probably doesn't make any sense. */
position: relative;
}
.rechercheProduit .glyphicon-search {
/* 'absolute' in the .input-group-addon context */
position: absolute;
top: auto;
bottom: 0;
left: 5px;
height: 80%;
width: auto;
overflow: hidden;
}
.rechercheProduit .glyphicon-search:before {
content: '';
display: block;
width: 50px; /* Generic width */
height: 100%;
background: url('http://i.stack.imgur.com/vr0uy.png') no-repeat;
background-size: auto 100%;
}
.rechercheProduit .text-upper-style {
/* relative to its context. Especially here to deal with the display order. */
position: relative;
margin-left: 20px;
}
Demo 1
Custom span
Another solution, which would probably be better, would be to
actually create your own span with your own pseudo-element (CSS is
similar to the last example, renaming the .glyphicon-search part
obviously):
<span class="input-group-addon">
<span class="search-icon"></span>
<span class="hidden-xs text-upper-style">
Rechercher</span>
</span>
Demo 2
Image
Even if I personally prefer having the icon as a background image
here (have a look on this question and its answers), declaring
the icon as an image is another solution that works.
c.f. the answer of tmg about that.
About the rest
To go beyond with your code, you should think about the fact that you are working in a form with an input[type="text"] as main input.
You’ll have to submit this form and unless you deal with a click event on this main span to submit your form, you’ll have to declare your rechercher span as an input as well (type=“submit”).
That would be semantically more correct and easier for you to deal with this button action in the future.
My final proposition would then be:
(also considering the "custom" span icon solution)
<div class="input-group">
<input type="text" class="form-control" placeholder="Rechercher un produit, une référence ...">
<label class="input-group-addon">
<span class="search-icon"></span>
<input type="submit" value="Rechercher" class="hidden-xs text-upper-style" />
</label>
</div>
-
.text-upper-style {
background: none;
text-transform: uppercase;
border: 0;
outline: 0;
}
.rechercheProduit .input-group-addon {
border: 0;
}
Demo 3
About the responsive, just declare a min-width on your label:
.rechercheProduit .input-group-addon {
min-width: 40px;
overflow: hidden;
}
Hope this makes sense. I'm open to any kind of suggestion, edit, etc...
Bon chance!
It's as easy as replace span glyphicon tag for your custom image tag forcing correct height and deleting top and bottom padding from text 'rechercher'.
So, add this to your html:
<span class="input-group-addon">
<img height="25" src="http://i.stack.imgur.com/vr0uy.png" alt="custom-magnifier">
<span class="hidden-xs text-upper-style">
Rechercher</span>
</span>
So, add this to your css:
.rechercheProduit .input-group-addon {
padding: 0 12px;
}
.rechercheProduit .input-group-addon {
vertical-align: bottom;
}
Here you have an example:
http://www.bootply.com/CAPEgZTt3J
You have to hide the default glyphicon then use custom image.
Try these lines:
.glyphicon-search::before {
content:none!important;
}
.glyphicon-search {
background-image:url(../ur-image);
height:20px;
width:20px;
background-repeat:no-repeat;
background-size:cover;
}
Here is the css that will replace the search icon
.glyphi {
background: rgba(0, 0, 0, 0) url("http://i.stack.imgur.com/vr0uy.png") no-repeat scroll 0 0 / contain;
display: inline-block;
font-style: normal;
font-weight: 400;
height: 16px;
line-height: 1;
position: relative;
top: 1px;
width: 60px;
}
You also need to resize the search icon because the parent element has padding.
This is my attemp, i hope this one can help you. i use absolute. Just try to view in full page, i working the responsive design.
* {
border-radius: 0 !important;
}
.rechercheProduit .input-group-addon {
border: 0px;
color: #ffffff;
background: #004392;
cursor: pointer;
}
.rechercheProduit:hover {
color: #fbba00;
}
.rechercheProduit .form-control,
.rechercheProduit .input-group-addon {
border: solid 2px #004392;
}
.rechercheProduit .input-group-addon {
-moz-border-radius: 0;
-webkit-border-w: 0;
border-radius: 0;
color: #ffffff;
background: #004392;
cursor: pointer;
}
.rechercheProduit .input-group-addon:hover {
color: #fbba00;
}
.text-upper-style {
text-transform: uppercase;
padding-left: 20px;
}
.glyphicon-search:before {
background: url(http://i.stack.imgur.com/vr0uy.png)center center;
background-size: contain;
background-repeat: no-repeat;
height: 25px;
width: 42px;
content: '';
z-index: 99;
position: absolute;
top: -15px;
left: -8px;
}
.glyphicon-search:before{
content: '' !important;
}
#media screen and (max-width: 767px){
.cus-icon{
padding: 0 10px;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-xs-8 col-md-6">
<form class="form-horizontal rechercheProduit">
<div class="input-group">
<input type="text" class="form-control" placeholder="Rechercher un produit, une référence ...">
<span class="input-group-addon">
<span aria-hidden="true" class="glyphicon glyphicon-search cus-icon"></span>
<span class="hidden-xs text-upper-style">
Rechercher</span>
</span>
</div>
</form>
</div>
One way would be to use a background-image on the input-group-addon + some padding-left and remove the glyphicon entirely:
* {
border-radius: 0 !important;
}
.rechercheProduit .input-group-addon {
border: 0px;
color: #ffffff;
background: #004392;
cursor: pointer;
}
.rechercheProduit:hover {
color: #fbba00;
}
.rechercheProduit .form-control,
.rechercheProduit .input-group-addon {
border: solid 2px #004392;
}
.rechercheProduit .input-group-addon {
-moz-border-radius: 0;
-webkit-border-w: 0;
border-radius: 0;
color: #ffffff;
background: #004392;
cursor: pointer;
background-image: url("http://i.stack.imgur.com/vr0uy.png");
background-position: 6px 3px;
background-repeat: no-repeat;
background-size: contain;
padding-left: 38px;
}
.rechercheProduit .input-group-addon:hover {
color: #fbba00;
}
.text-upper-style {
text-transform: uppercase;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="col-xs-8 col-md-6">
<form class="form-horizontal rechercheProduit">
<div class="input-group">
<input class="form-control" placeholder="Rechercher un produit, une référence ..." type="text">
<span class="input-group-addon">
<span class="text-upper-style">
Rechercher</span>
</span>
</div>
</form>
</div>
You need of course to change the background-position, background-size, padding-left so it fits your image.
Adjust the background-size to define the size of the image, change the background-position to position the image inside the span and change the padding-left value to move the text further to the right.
You can override .glyphicon and set your image as a background for it and remove its icon
.rechercheProduit .input-group-addon span.glyphicon{
background: url(http://i.stack.imgur.com/vr0uy.png);
background-size: 100% 100%;
height: 24px;
width: 38px;
vertical-align: text-bottom;
margin: -6px -13px 0 0;
top: auto;
bottom: -6px;
z-index: 0;
}
.rechercheProduit .input-group-addon span.glyphicon:before{
content:''; // To remove its default icon
}
https://jsfiddle.net/ms5e0535/

How to place background with text over another background image without HTML

I made a form with checkbox as a forest image. I need to place another transparent background with text from html parameter (data-forest) over the forest checbox image but I have to do this only by CSS. I've tried so many solutions but no one work properly. Anyone have some idea?
Final effect on hover:
JsFiddle: https://jsfiddle.net/ac9z8sgd/
HTML
<form action="action" method="get">
<input type="hidden" name="test" value="test" />
<ul>
<li><input id="checkbox" type="checkbox" name="forest_type" value="forest_1"><label for="checkbox_forest" data-forest="Estern forest">Forest 1</label></li>
</ul>
<button type="submit">Submit</button>
</form>
CSS
/* Default check button */
#checkbox + label {
background: url('http://i.imgur.com/Ds7gh7b.jpg?1');
background-repeat: no-repeat;
height: 250px;
width: 250px;
padding: 15px 15px;
display: inline-block;
position: relative;
}
/* Hover action */
#checkbox + label[data-forest]:hover {
background: rgba(0,0,0,0.8);
content: attr(data-forest);
display: inline-block;
font-size: 20px;
color: white;
position: relative;
}
Use a pseudo-element.
/* Default check button */
#checkbox + label {
background: url('http://i.imgur.com/Ds7gh7b.jpg?1');
background-repeat: no-repeat;
height: 275px;
width: 184px;
display: inline-block;
position: relative;
}
/* Hover action */
#checkbox + label[data-forest]:hover::after {
background: rgba(0, 0, 0, 0.8);
content: attr(data-forest);
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 50%;
font-size: 20px;
color: white;
display: flex;
}
<form action="action" method="get">
<input type="hidden" name="test" value="test" />
<ul>
<li>
<input id="checkbox" type="checkbox" name="forest_type" value="forest_1">
<label for="checkbox_forest" data-forest="Estern forest">Forest 1</label>
</li>
</ul>
<button type="submit">Submit</button>
</form>
JSfiddle with Transitions
My suggestion:
label[data-forest]:hover:before {
background: rgba(0,0,0,0.8);
content: attr(data-forest);
font-size: 20px;
color: white;
margin-top: 240px;
margin-left: -15px;
position: absolute;
width: 100%;
text-align: center;
}
BTW: Maybe 0.8 is too much a high value for a perceptible transparency. I'd make it 0.4.

Custom placeholder in input with icon

I am trying to make a custom placeholder for my "Search" input. It should look like a search icon (using Bootstrap glyphicon glyphicon-search classes for that) and then the word "Search", inside the input element, just as a placeholder looks like, and centered.
I am trying to position the div containing these to elements inside the input but I can't get it right.
Here's the code in jsfiddle.
HTML:
<div class="search-wrapper">
<form class="post_search" id="post_search" action="/posts/explore" accept-charset="UTF-8" method="get"><input name="utf8" type="hidden" value="✓">
<input autocomplete="off" class="search-input" type="search" name="q[caption_or_user_user_name_cont]" id="q_caption_or_user_user_name_cont">
<div class="placeholder">
<div>
<span class="glyphicon glyphicon-search"></span>
<span>Search</span>
</div>
</div>
</form>
</div>
CSS:
.search-wrapper {
max-width: 340px;
margin: 0 auto;
text-align: center;
margin-top: 20px;
display: inline;
}
.search-wrapper .search-input {
border: 1px solid #ddd;
border-radius: 15px;
background-color: #eee;
width: 220px;
height: 31px;
padding: 10px 15px;
transition: 0.25s all;
}
.search-wrapper .search-input:focus {
outline: 0 none;
background-color: #fff;
transition: 0.25s all;
}
.search-wrapper .placeholder {
display: inline;
position: relative;
top: 30%;
width: 40px;
margin: 0 auto;
text-align: center;
font-size: 10px;
}
Then when focusing on the input the placeholder should be gone, I guess this shouldn't be difficult with some js.
But back to the issue, what am I doing wrong? How can I display the placeholder as intented?
Why not simplify this enormously? You already have the placeholder built into HTML! Here's what you can do:
input[type="search"]::-webkit-input-placeholder:before {
content: "\e003 ";
font-family: 'Glyphicons Halflings';
}
input[type="search"]:-moz-placeholder:before {
content: "\e003 ";
font-family: 'Glyphicons Halflings';
input[type="search"]::-moz-placeholder:before {
content: "\e003 ";
font-family: 'Glyphicons Halflings';
}
input[type="search"]:-ms-input-placeholder:before {
content: "\e003 ";
font-family: 'Glyphicons Halflings';
}
<input type='search' placeholder='search here' />
Now don't be worried, the icon isn't displaying here because I haven't included font-awesome (or whatever the Glyphicons Halflings font is provided by), but this makes it tremendously simply to create a nice placeholder. It even works like one! It also reduces your code greatly, although browser support is a little less stellar (it really depends how far back you want to go).
Font Awesome uses the unicode glyphs and a font with all those icons included, so as long as you use the right font and copy in the correct character into your content property, this will work.
this was tested in Safari and Chrome
My solution:
https://jsfiddle.net/83x8tfwp/6/
HTML:
<div class="search-wrapper">
<form class="post_search" id="post_search" action="/posts/explore" accept-charset="UTF-8" method="get"><input name="utf8" type="hidden" value="✓">
<input autocomplete="off" class="search-input" type="search" name="q[caption_or_user_user_name_cont]" id="q_caption_or_user_user_name_cont">
<div class="placeholder">
<div>
<span class="glyphicon glyphicon-search"></span>
<span>Search</span>
</div>
</div>
</form>
</div>
CSS:
.search-wrapper {
max-width: 280px;
margin: 0 auto;
text-align: center;
margin-top: 20px;
position: relative;
color: #aaa;
}
.search-wrapper .search-input {
border: 1px solid #ddd;
border-radius: 15px;
background-color: #eee;
width: 220px;
height: 31px;
padding: 3px 15px;
transition: 0.25s all;
}
.search-wrapper .search-input:focus {
outline: 0 none;
background-color: #fff;
transition: 0.25s all;
}
.search-wrapper .search-input:focus + .placeholder {
display: none;
}
.search-wrapper .placeholder {
position: absolute;
top: 8px;
left: 38%;
margin: 0 auto;
text-align: center;
font-size: 13px;
}
JavaScript:
$('.placeholder').on('click', function() {
$('.search-input').focus();
});
if ($('.search-input').val()) {
$('.placeholder').hide();
}
$('.search-input').on('blur', function() {
if (!$('.search-input').val()) {
$('.placeholder').show();
}
});
$('.search-input').on('focus', function() {
if (!$('.search-input').val()) {
$('.placeholder').hide();
}
});
$('.search-input').on('input', function() {
if ($('.search-input').val()) {
$('.placeholder').hide();
}
});

changing the Style of Radio buttons in jQuery mobile 1.4.0

I have the Following Radio buttons in my jQuery mobile app , I need to style them as the Radio button in the image bellow . I have tried the following css but it didn't give me the same result , Please Help me ..
Html
<div data-role="page">
<div data-role="header" data-theme="b" style="height:63px;">
</div>
<div data-role="content">
<form>
<fieldset>
<input type="radio" id="Male" value=" Male" name="radio-group-1" />
<label for="Male" data-inline="true" style="background:transparent !important;">Male </label>
<input type="radio" id="Female" value=" Female" name="radio-group-1" />
<label for="Female" data-inline="true" style="background:transparent !important;" >Female </label>
</fieldset>
</form>
</div>
</div>
CSS
input[type="radio"] {
display: none;
}
.ui-btn.ui-radio-off:after, .ui-btn.ui-radio-on:after{
width: 25px;
height: 25px;
}
.ui-btn.ui-radio-off:after, .ui-btn.ui-radio-on:after{
margin-top: -18px;
margin-left: -38px;
}
.ui-btn.ui-radio-on:after{
width: 55px;
height: 55px;
background: green !important;
background-size:100px 24px;
}
This is what i get
To get a green inner circle with transparent around it and a border after that, you really need 2 circles. This could be achieved by adding a :before element as well as the :after element in CSS.
Here is a DEMO
The CSS makes the whole button 56px tall and vertically centers the text by making the line-height the same. When off, the radio image is 26x26 with a gray border. When on, the :before css adds a new 26x26 empty circle with a border while the :after css creates a smaller green circle in the center. NOTE: you may need to tweak sizes and margins to get your desired results.
input[type="radio"] {
display: none;
}
.ui-radio label {
height:56px;
line-height: 56px;
padding-left: 50px;
}
.ui-radio .ui-btn.ui-radio-off:after {
background-image: none;
width: 26px;
height: 26px;
border: 2px solid #6E7983;
margin-top: -13px;
}
.ui-radio .ui-btn.ui-radio-on:after {
background-color: #86D51C;
width: 14px;
height: 14px;
margin-top: -6px;
margin-left: 10px;
border: 0;
}
.ui-radio .ui-btn.ui-radio-on:before {
content:"";
position: absolute;
display: block;
border: 2px solid #6E7983;
border-radius: 50%;
background-color: transparent;
width: 26px;
height: 26px;
margin-top: 14px;
margin-left: -39px;
}

Resources