:checked css not working - html

I have a product listing little square thing, when I click it ( it's a label ) it should tick the box and it does but it should make the border green and hold it but it doesn't I have this:
.product {
width: 100%;
background: #fff;
border: 4px solid #fff;
border-radius: 4px;
margin-bottom: 20px;
box-shadow: 0 2px 3px #ddd;
text-align:center;
padding-bottom: 15px;
cursor: pointer;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-o-transition: all .3s ease;
-ms-transition: all .3s ease;
transition: all .3s ease;
a {
color: #d6d6d6;
line-height: 25px;
border-radius: 100%;
background: #f2f2f2;
width: 25px;
height: 25px;
display: block;
position: absolute;
margin: 10px;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-o-transition: all .3s ease;
-ms-transition: all .3s ease;
transition: all .3s ease;
&:hover {
background: #e2e1e1;
color: #333;
text-decoration: none
}
}
img {
width: 80%;
margin: 15px auto;
pointer-events: none;
}
span {
display: block;
&.brand {
color: #cdcfd2;
font-size: 13px;
font-weight: 300;
}
&.name {
color: #232f3e;
font-size: 16px;
font-weight: 600;
}
}
&:hover {
border: 4px solid #d9dce1;
box-shadow: none;
}
}
and this works great it's .less my html looks like this:
<div class="col-md-2">
<label for="product_id" name="product_id" class="product">
i
<div class="position">
<input type="checkbox" class="checkbox" name="product_id" id="product_id">
</div>
<img src="assets/images/products/image.jpg">
<span class="brand">Brand</span>
<span class="name">Product</span>
</label>
How do I would I apply the suggestions in this checked: example?
input[type=checkbox]:checked + label { }
It looks pretty simple but when I add it it doesn't work all I want is the .product border to be green instead of grey when it's selected
I know I can use js but I don't want to css should do it.

+ is an adjacent sibling selector, meaning it matches the element after it based on the selector. Simply add a label tag after your <input type="checkbox"> tag.
.product {
width: 100%;
background: #fff;
border: 4px solid #fff;
border-radius: 4px;
margin-bottom: 20px;
box-shadow: 0 2px 3px #ddd;
text-align: center;
padding-bottom: 15px;
cursor: pointer;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-o-transition: all .3s ease;
-ms-transition: all .3s ease;
transition: all .3s ease;
}
.product a {
color: #d6d6d6;
line-height: 25px;
border-radius: 100%;
background: #f2f2f2;
width: 25px;
height: 25px;
display: block;
position: absolute;
margin: 10px;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-o-transition: all .3s ease;
-ms-transition: all .3s ease;
transition: all .3s ease;
}
.product a:hover {
background: #e2e1e1;
color: #333;
text-decoration: none;
}
.product img {
width: 80%;
margin: 15px auto;
pointer-events: none;
}
.product span {
display: block;
}
.product span.brand {
color: #cdcfd2;
font-size: 13px;
font-weight: 300;
}
.product span.name {
color: #232f3e;
font-size: 16px;
font-weight: 600;
}
.product:hover {
border: 4px solid #d9dce1;
box-shadow: none;
}
input[type=checkbox]:checked + label {
color: red;
}
<div class="col-md-2">
<label for="product_id" name="product_id" class="product">
i
<div class="position">
<input type="checkbox" class="checkbox" name="product_id" id="product_id">
<label for="product_id">label</label>
</div>
<img src="assets/images/products/image.jpg">
<span class="brand">Brand</span>
<span class="name">Product</span>
</label>

to work "+" tags need to go one by one
css:
input[type=checkbox]:checked + label { }
html:
<input type="checkbox" id="id"><label for="id">...</label>
input[type=checkbox]:checked + label {
background-color: red;
}
<input type="checkbox" id="id">
<label for="id">Test</label>

For anyone struggling
The input and the element that you're modifying need to be directly next to the each other, for the :checked rule to work.
#hidden {
display: none;
height: 100px;
background: red;
}
:checked + #hidden {
display: block;
}
<input type="checkbox" id="my_checkbox" style="display:none;">
<!-- NEED TO BE NEXT TO EACH OTHER ^ -->
<div id="hidden"></div>
<label for="my_checkbox">Show/hide</label>

Related

Checkbox ON/OFF switch in Safari and IE/Edge

In Chrome, firefox, opera, brave ia ok, in Safari - transition no good.
In Edge, Internet Esplorer - apprearance not work, looks like the checkbox
How to repear safari's transition and apprearance in Edge/IE browsers?
.mytoggle {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
width: 80px;
height: 30px;
display: inline-block;
position: relative;
border-radius: 15px;
overflow: hidden;
outline: none;
border: none;
cursor: pointer;
background-color: #bdc3c7;
-webkit-transition: .25s ease-in-out;
-moz-transition: .25s ease-out;
-o-transition: .25s ease-out;
transition: .25s ease-out;
}
.mytoggle:before {
width: 22px;
height: 22px;
left: 4px;
top: 4px;
border-radius: 11px;
z-index: 2;
content: "ON OFF";
display: block;
position: absolute;
background: #7f8c9a;
font-size: 14.99px;
font-weight: 700;
text-transform: uppercase;
text-indent: -32px;
word-spacing: 40px;
color: #fff;
white-space: nowrap;
-webkit-transition: .25s ease-out;
-moz-transition: .25s ease-out;
-o-transition: .25s ease-out;
transition: .25s ease-out;
}
.mytoggle:checked {
background-color: #2A3542;
}
input.mytoggle:focus {
outline: 0;
}
.mytoggle:checked:before {
background-color: #41cac0;
color: #41cac0;
left: 54px;
}
<input type="checkbox" checked="checked" class="mytoggle" style="" />
Styling a checkbox directly is a pain, you could use the checkbox + label hack, in which you link a label to a checkbox, and apply the styles to the label instead of the checkbox itself:
.mytoggle {
visibility: hidden;
opacity: 0;
position: absolute;
top: -99999px;
}
.mytoggle + label {
font-family: arial;
vertical-align: middle;
width: 80px;
height: 30px;
display: inline-block;
position: relative;
border-radius: 15px;
overflow: hidden;
outline: none;
border: none;
cursor: pointer;
background-color: #bdc3c7;
-webkit-transition: .25s ease-in-out;
-moz-transition: .25s ease-out;
-o-transition: .25s ease-out;
transition: .25s ease-out;
}
.mytoggle + label:before {
width: 22px;
height: 22px;
left: 4px;
top: 4px;
border-radius: 11px;
z-index: 2;
content: "ON OFF";
display: block;
position: absolute;
background: #7f8c9a;
font-size: 14.99px;
font-weight: 700;
text-transform: uppercase;
text-indent: -32px;
word-spacing: 40px;
color: #fff;
white-space: nowrap;
-webkit-transition: .25s ease-out;
-moz-transition: .25s ease-out;
-o-transition: .25s ease-out;
transition: .25s ease-out;
}
.mytoggle:checked + label {
background-color: #2A3542;
}
input.mytoggle:focus + label {
outline: 0;
}
.mytoggle:checked + label:before {
background-color: #41cac0;
color: #41cac0;
left: 54px;
}
<input type="checkbox" checked="checked" class="mytoggle" id="mycheckbox" />
<label for="mycheckbox" />
input { opacity:0}
input+label {
width: 80px;
height: 30px;
display: inline-block;
position: relative;
border-radius: 15px;
overflow: hidden;
outline: none;
border: none;
cursor: pointer;
background-color: #bdc3c7;
-webkit-transition: .25s ease-in-out;
-moz-transition: .25s ease-out;
-o-transition: .25s ease-out;
transition: .25s ease-out;
}
input+label:before {
width: 22px;
height: 22px;
left: 4px;
top: 4px;
border-radius: 11px;
z-index: 2;
content: "ON OFF";
display: block;
position: absolute;
background: #7f8c9a;
font-size: 14.99px;
font-weight: 700;
text-transform: uppercase;
text-indent: -32px;
word-spacing: 40px;
color: #fff;
white-space: nowrap;
-webkit-transition: .25s ease-out;
-moz-transition: .25s ease-out;
-o-transition: .25s ease-out;
transition: .25s ease-out;
}
input:checked+label{
background-color: #2A3542;
}
input.mytoggle:focus {
outline: 0;
}
input:checked+label:before {
background-color: #41cac0;
color: #41cac0;
left: 54px;
}
<input type="checkbox" name="abc" id="abc" checked="checked" style="" />
<label for="abc" class="mytoggle"></label>
I just added a label for input checkbox, tested in internet explorer 11. I don't have have safari browser to test it, So you can test and let know, if this answer meets your requirement.
Please try this.
$(document).ready(function(e) {
$(".ra-box").click(function(){
$(this).toggleClass('checked');
});
});
input[type=checkbox] { opacity: 0; }
.ra-box {
display: inline-block;
margin: 0;
padding: 6px;
cursor: pointer;
border-radius: 15px;
overflow: hidden;
background: #2a3542;
width: 70px;
height: 18px;
position: relative;
}
.ra-box:before {
height: 20px;
width: 20px;
background: #41cac0;
color: #41cac0;
content: 'ON';
text-indent: -40px;
position: absolute;
top: 5px;
right: 5px;
border-radius: 50%;
}
.ra-box:after {
height: 20px;
width: 20px;
background: #7f8c9a;
color: #fff;
content: 'OFF';
position: absolute;
top: 5px;
border-radius: 50%;
text-indent: 30px;
left: 85px;
}
/* Check Box Check Change background color */
.ra-box.checked:before { right: 85px; }
.ra-box.checked:after { left: 5px;}
.ra-box.checked { background: #bdc3c7; }
.ra-box,.checked,.ra-box.checked,.ra-box:before,.ra-box:after,.ra-box.checked:before,.ra-box.checked:after {
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
-ms-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="ra-box">
<input type="checkbox" id="toggle-1">
</div>
<br>
<br>
<div class="ra-box">
<input type="checkbox" id="toggle-1">
</div>

How to make :hover affect a non child-element

I've tried using the :before and :after pseudos to change the information displayed when hovering over one of the radio buttons. However, due to the fact that they are not child-elements, I can not seem to make it work.
What I'm trying to achieve is:
When you hover over radio button 1, the information1 element shows.
When radio button 1 is in :checked stage, the information1 element needs to remain displayed.
The same for radio button 2.
What am I doing wrong here?
<form method="post" action="#">
<div class="row uniform">
<div class="3u 12u$(xsmall)">
<input type="radio" class="radio1" id="radio1" name="group">
<label for="radio1"></label>
</div>
<div class="3u 12u$(xsmall)">
<input type="radio" class="radio2" id="radio2" name="group">
<label for="radio2"></label>
</div>
<div class="6u 12u$(xsmall)">
<p class="information1">information1</p>
<p class="information2">information2</p>
</div>
<div class="12u$">
<ul class="actions">
<li><input type="submit" value="Submit" /></li>
</ul>
</div>
</div>
</form>
/* Radio1 */
input[type="radio"].radio1 {
-moz-appearance: none;
-webkit-appearance: none;
-ms-appearance: none;
appearance: none;
display: block;
float: left;
margin-right: -2rem;
opacity: 0;
width: 1rem;
z-index: -1;
}
input[type="radio"].radio1+label {
border-radius: 4px;
border: solid 3px;
border-color: #D2D2D2;
color: #888;
display: inline-block;
background-image: url(radio1.png);
height: 156px;
width: 106px;
line-height: 1.725rem;
position: relative;
cursor: pointer;
text-align: left;
-moz-transition: all 0.4s ease-in-out;
-webkit-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}
input[type="radio"].radio1:hover+label {
border-color: #BBBBBB;
background-image: url(radio1_hover.png);
-moz-transition: all 0.4s ease-in-out;
-webkit-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}
input[type="radio"].radio1:checked+label {
background-image: url(radio1_focus.png);
border-color: #51CCA8;
}
input[type="radio"].radio1:checked+label:before {
content: '\f00c';
color: white;
font-size: 1.5rem;
background-color: #4DC29F;
border-radius: 4px;
border: solid 3px;
border-color: #4DC29F;
position: absolute;
top: 56px;
left: 33px;
}
/* Radio2 */
input[type="radio"].radio2 {
-moz-appearance: none;
-webkit-appearance: none;
-ms-appearance: none;
appearance: none;
display: block;
float: left;
margin-right: -2rem;
opacity: 0;
width: 1rem;
z-index: -1;
}
input[type="radio"].radio2+label {
border-radius: 4px;
border: solid 3px;
border-color: #D2D2D2;
color: #888;
display: inline-block;
background-image: url(radio2.png);
height: 156px;
width: 106px;
line-height: 1.725rem;
position: relative;
cursor: pointer;
text-align: left;
-moz-transition: all 0.4s ease-in-out;
-webkit-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}
input[type="radio"].radio2:hover+label {
border-color: #BBBBBB;
background-image: url(radio2_hover.png);
-moz-transition: all 0.4s ease-in-out;
-webkit-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}
input[type="radio"].radio2:checked+label {
background-image: url(radio2_focus.png);
border-color: #51CCA8;
}
input[type="radio"].radio2:checked+label:after {
content: '\f00c';
color: white;
font-size: 1.5rem;
background-color: #4DC29F;
border-radius: 4px;
border: solid 3px;
border-color: #4DC29F;
position: absolute;
top: 56px;
left: 33px;
}
You can accomplish that with a bit of javascript:
function getIndex(elem, attr) {
return $(elem).attr(attr).substr(5);
}
$('label')
.mouseover(function(ev) {
$('.information' + getIndex(ev.currentTarget, 'for')).show();
})
.mouseout(function(ev) {
var index = getIndex(ev.currentTarget, 'for');
if (!$('#radio' + index).is(':checked'))
$('.information' + index).hide();
});
$('input[type=radio]')
.change(function(ev) {
$('p').hide();
$('.information' + getIndex(ev.currentTarget, 'id')).show();
});
.information1,
.information2 {
display: none;
}
/* Radio1 */
input[type="radio"].radio1 {
-moz-appearance: none;
-webkit-appearance: none;
-ms-appearance: none;
appearance: none;
display: block;
float: left;
margin-right: -2rem;
opacity: 0;
width: 1rem;
z-index: -1;
}
input[type="radio"].radio1+label {
border-radius: 4px;
border: solid 3px;
border-color: #D2D2D2;
color: #888;
display: inline-block;
background-image: url(radio1.png);
height: 156px;
width: 106px;
line-height: 1.725rem;
position: relative;
cursor: pointer;
text-align: left;
-moz-transition: all 0.4s ease-in-out;
-webkit-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}
input[type="radio"].radio1:hover+label {
border-color: #BBBBBB;
background-image: url(radio1_hover.png);
-moz-transition: all 0.4s ease-in-out;
-webkit-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}
input[type="radio"].radio1:checked+label {
background-image: url(radio1_focus.png);
border-color: #51CCA8;
}
input[type="radio"].radio1:checked+label:before {
content: '\f00c';
color: white;
font-size: 1.5rem;
background-color: #4DC29F;
border-radius: 4px;
border: solid 3px;
border-color: #4DC29F;
position: absolute;
top: 56px;
left: 33px;
}
/* Radio2 */
input[type="radio"].radio2 {
-moz-appearance: none;
-webkit-appearance: none;
-ms-appearance: none;
appearance: none;
display: block;
float: left;
margin-right: -2rem;
opacity: 0;
width: 1rem;
z-index: -1;
}
input[type="radio"].radio2+label {
border-radius: 4px;
border: solid 3px;
border-color: #D2D2D2;
color: #888;
display: inline-block;
background-image: url(radio2.png);
height: 156px;
width: 106px;
line-height: 1.725rem;
position: relative;
cursor: pointer;
text-align: left;
-moz-transition: all 0.4s ease-in-out;
-webkit-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}
input[type="radio"].radio2:hover+label {
border-color: #BBBBBB;
background-image: url(radio2_hover.png);
-moz-transition: all 0.4s ease-in-out;
-webkit-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}
input[type="radio"].radio2:checked+label {
background-image: url(radio2_focus.png);
border-color: #51CCA8;
}
input[type="radio"].radio2:checked+label:after {
content: '\f00c';
color: white;
font-size: 1.5rem;
background-color: #4DC29F;
border-radius: 4px;
border: solid 3px;
border-color: #4DC29F;
position: absolute;
top: 56px;
left: 33px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form method="post" action="#">
<div class="row uniform">
<div class="3u 12u$(xsmall)">
<input type="radio" class="radio1" id="radio1" name="group">
<label for="radio1"></label>
</div>
<div class="3u 12u$(xsmall)">
<input type="radio" class="radio2" id="radio2" name="group">
<label for="radio2"></label>
</div>
<div class="6u 12u$(xsmall)">
<p class="information1">information1</p>
<p class="information2">information2</p>
</div>
<div class="12u$">
<ul class="actions">
<li><input type="submit" value="Submit" /></li>
</ul>
</div>
</div>
</form>
Only CSS solution (added code on top), changing the HTML code:
.information1,
.information2 {
display: none;
}
input[type="radio"].radio1:hover+label+p,
input[type="radio"].radio2:hover+label+p,
input[type="radio"].radio1:checked+label+p,
input[type="radio"].radio2:checked+label+p {
display:block;
}
/* Radio1 */
input[type="radio"].radio1 {
-moz-appearance: none;
-webkit-appearance: none;
-ms-appearance: none;
appearance: none;
display: block;
float: left;
margin-right: -2rem;
opacity: 0;
width: 1rem;
z-index: -1;
}
input[type="radio"].radio1+label {
border-radius: 4px;
border: solid 3px;
border-color: #D2D2D2;
color: #888;
display: inline-block;
background-image: url(radio1.png);
height: 156px;
width: 106px;
line-height: 1.725rem;
position: relative;
cursor: pointer;
text-align: left;
-moz-transition: all 0.4s ease-in-out;
-webkit-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}
input[type="radio"].radio1:hover+label {
border-color: #BBBBBB;
background-image: url(radio1_hover.png);
-moz-transition: all 0.4s ease-in-out;
-webkit-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}
input[type="radio"].radio1:checked+label {
background-image: url(radio1_focus.png);
border-color: #51CCA8;
}
input[type="radio"].radio1:checked+label:before {
content: '\f00c';
color: white;
font-size: 1.5rem;
background-color: #4DC29F;
border-radius: 4px;
border: solid 3px;
border-color: #4DC29F;
position: absolute;
top: 56px;
left: 33px;
}
/* Radio2 */
input[type="radio"].radio2 {
-moz-appearance: none;
-webkit-appearance: none;
-ms-appearance: none;
appearance: none;
display: block;
float: left;
margin-right: -2rem;
opacity: 0;
width: 1rem;
z-index: -1;
}
input[type="radio"].radio2+label {
border-radius: 4px;
border: solid 3px;
border-color: #D2D2D2;
color: #888;
display: inline-block;
background-image: url(radio2.png);
height: 156px;
width: 106px;
line-height: 1.725rem;
position: relative;
cursor: pointer;
text-align: left;
-moz-transition: all 0.4s ease-in-out;
-webkit-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}
input[type="radio"].radio2:hover+label {
border-color: #BBBBBB;
background-image: url(radio2_hover.png);
-moz-transition: all 0.4s ease-in-out;
-webkit-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}
input[type="radio"].radio2:checked+label {
background-image: url(radio2_focus.png);
border-color: #51CCA8;
}
input[type="radio"].radio2:checked+label:after {
content: '\f00c';
color: white;
font-size: 1.5rem;
background-color: #4DC29F;
border-radius: 4px;
border: solid 3px;
border-color: #4DC29F;
position: absolute;
top: 56px;
left: 33px;
}
<form method="post" action="#">
<div class="row uniform">
<div class="3u 12u$(xsmall)">
<input type="radio" class="radio1" id="radio1" name="group">
<label for="radio1"></label>
<p class="information1">information1</p>
</div>
<div class="3u 12u$(xsmall)">
<input type="radio" class="radio2" id="radio2" name="group">
<label for="radio2"></label>
<p class="information2">information2</p>
</div>
<div class="12u$">
<ul class="actions">
<li><input type="submit" value="Submit" /></li>
</ul>
</div>
</div>
</form>

CSS and HTML change after value and type of link

I'm working in Dot Net Nuke on a website that has been previously setup. I want to add a css button I found on the internet. I put the html in the html fields and css in the stylesheet editor.
when a link is created it automatically adds ">>" after the link text. In other buttons css buttons I used I managed to remove that, but with this button I can't remove it. Also I want the button to link to another page using "a href". How would i make this possible?
Button HTML:
<div class="btn-container">
<input type="submit" value="button" id="button-blue"/>
<div class="ease"></div>
</div>
Button CSS:
#button-blue {
float: left;
width: 100%;
max-width: 500px;
border: white solid 4px;
cursor: pointer;
background-color: #0493bd;
margin-top: -4px;
color: white;
text-transform: uppercase;
font-family: Arial, Helvetica, sans-serif;
font-size: 20px;
letter-spacing: .1em;
padding-top: 22px;
padding-bottom: 22px;
font-weight: 500;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
-ms-transition: all 0.3s;
transition: all 0.3s;
}
/* Change text color & background opacity on hover*/
#button-blue:hover {
background-color: rgba(0,0,0,0);
color: #0493bd;
}
/* The white hover effect */
.ease {
width: 0px;
height: 70px;
background-color: white;
-webkit-transition: .3s ease;
-moz-transition: .3s ease;
-o-transition: .3s ease;
-ms-transition: .3s ease;
transition: .3s ease;
}
/* Make visable when hover */
.btn-container:hover .ease {
width: 100%;
max-width: 500px;
background-color: white;
border: 0;
}
.btn-container:after {
display: none !important;
}
well you want the button to link to another page, to do that you can simply style your href to look as a button like this (Run the following snippet) -
Submit
<style>
#submit-btn{
display :inline-block;
text-decoration:none;
background-color:blue;
border-radius:4px;
padding:5px 10px;
color:white;
}
</style>
Well for the issue of >> after every link it may be some css that is adding it, which you haven't posted in your question so try adding following code which may remove it..
a:after {
content: none !important;
}
OR this one -
a:after {
display: none !important;
}
or just for the link like button I posted above try this -
#submit-btn:after {
content: none !important;
}
OR
#submit-btn:after {
display: none !important;
}
NOTE - Since you are overwriting CSS don't forget to add !important..
Change to button to href
<div class="btn-container">
Button
<div class="ease"></div>
</div>
CSS
#button-blue{
float:left;
width: 100%;
max-width:500px;
border: white solid 4px;
cursor: pointer;
background-color: #0493bd;
margin-top: -4px;
color: white;
text-transform: uppercase;
font-family: Arial, Helvetica, sans-serif;
font-size: 20px;
letter-spacing: .1em;
padding-top: 22px;
padding-bottom: 22px;
font-weight: 500;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
-ms-transition: all 0.3s;
transition: all 0.3s;
text-align:center;
}
/* Change text color & background opacity on hover*/
#button-blue:hover{
background-color: rgba(0,0,0,0);
color: #0493bd;
}
#button-blue:after{content:">>"}
/* The white hover effect */
.ease {
width: 0px;
height: 70px;
background-color: white;
-webkit-transition: .3s ease;
-moz-transition: .3s ease;
-o-transition: .3s ease;
-ms-transition: .3s ease;
transition: .3s ease;
}
/* Make visable when hover */
.btn-container:hover .ease{
width: 100%;
max-width: 500px;
background-color: white;
border: 0;
}
.btn-container:after {
display: none !important;
}
demo link
https://jsfiddle.net/0zctLenb/

Move checkbox label when box is checked

I'm looking for some help to move my checkbox label after the label has been checked. When it starts out, the label is in the middle of the code. After I click on it, however, I would like for it to be moved. I thought that I had it, but it doesn't look that way now. Is there anybody that would be willing to lend a hand?
JSFiddle: http://jsfiddle.net/50c419nL/4/
Markup:
<div id="vera-gallery">
<div class="vera-check">
<label for="vone">e x i l e</label>
<input type="checkbox" id="vone" name="main" />
<div class="vera-bar">I'm controlled by toggle. No JavaScript!</div>
</div>
</div>
CSS:
#vera-gallery {
width: 500px;
height: 500px;
overflow: hidden;
background-image:url(http://i.imgur.com/ZOmzzeE.png);
margin: auto;
position: relative;
}
#vera-gallery input[type=checkbox] {
display: none;
}
.vera-check {
width: 500px;
height: 500px;
}
.vera-check input[type=checkbox] {
position: absolute;
top: 50%;
left: 50%;
}
.vera-check input[type=checkbox]:checked ~ .vera-bar {
margin-left: 0;
}
.vera-check label {
cursor: pointer;
}
.vera-check label[for=vone] {
top: 235px;
width: 80px;
text-align: center;
font-family: oxygen;
font-size: 8px;
text-transform: uppercase;
letter-spacing: 1px;
color: #fff;
text-align: center;
padding: 10px;
position: absolute;
background-color: rgba(0, 0, 0, 0.8);
left: 200px;
border: 1px solid #fff;
}
.vera-check input[type=checkbox]:checked ~ label[for=vone] {
top: 10px;
left: 10px;
}
.vera-bar {
width: 470px;
padding: 15px;
background-color: rgba(0, 0, 0, 0.8);
float: left;
top: 0px;
height: 100%;
font-family: oxygen;
font-weight: bold;
color: #fff;
margin-left: -500px;
transition: 0.5s all ease;
-webkit-transition: 0.5s all ease;
-moz-transition: 0.5s all ease;
-ms-transition: 0.5s all ease;
-o-transition: 0.5s all ease;
}
.vera-ships {
width: 225px;
padding: 15px;
background-color: rgba(0, 0, 0, 0.8);
float: left;
top: 0px;
height: 100%;
font-family: oxygen;
font-weight: bold;
color: #fff;
margin-left: -255px;
transition: 0.5s all ease;
-webkit-transition: 0.5s all ease;
-moz-transition: 0.5s all ease;
-ms-transition: 0.5s all ease;
-o-transition: 0.5s all ease;
}
.vera-two {
position: absolute;
}
.vera-two .vera-chk {
float: left
}
.vera-two input[type=checkbox] {
display: none
}
The general sibling selector will not work in this case, with the markup as-is, since the checkbox input does not precede the label.
The ~ combinator separates two selectors and matches the second
element only if it is preceded by the first, and both share a common
parent.
If, however, you move the label after the div, it works: http://jsfiddle.net/50c419nL/5/
<div id="vera-gallery">
<div class="vera-check">
<input type="checkbox" id="vone" name="main" />
<div class="vera-bar">I'm controlled by toggle. No JavaScript!</div>
<label for="vone">e x i l e</label><!-- moved to here -->
</div>
</div>

Styling Radio Inputs

So I'm having major trouble with styling radio buttons and as such I've managed to get it working perfectly in Chrome, a tiny bit in Firefox and not at all in IE.
This is the expected look (in Chrome):
This is how it looks in Firefox:
And IE...
I've got a JSFiddle for you guys to play around with, but I just can't seem to figure out how to get this working cross-browser. Any ideas?
JSFiddle: http://jsfiddle.net/s5rpd97b/
Obligatory paste of code despite the fact it's on JSFiddle anyway:
HTML:
<input style="background: url(http://socialavatarnetworkscript.com/media/img/male_avatar.png);margin-right: 240px;" class="gender" name="gender" type="radio" value="male">
<input style="background: url(http://socialavatarnetworkscript.com/media/img/female_avatar.png)" class="gender" name="gender" type="radio" value="female">
CSS:
input[type="radio"].gender::after{
background: rgba(0, 0, 0, 0.01);
position: absolute;
width: 170px;
height: 300px;
display: block;
content: '';
color: white;
font-size: 1px;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-ms-transition: all 0.2s ease;
-o-transition: all 0.2s ease;
transition: all 0.2s ease;
}
input[type="radio"].gender:checked::after{
background: rgba(0, 0, 0, 0.8);
position: absolute;
width: 170px;
height: 300px;
display: block;
content: 'SELECTED';
border-radius: 4px;
color: white;
font-family: titillium, sans-serif;
font-weight: 500;
font-size: 22px;
text-align: center;
line-height: 300px;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-ms-transition: all 0.2s ease;
-o-transition: all 0.2s ease;
transition: all 0.2s ease;
}
input[type="radio"]{
display: inline-block;
-webkit-appearance: none;
-moz-appearance: none;
-ms-appearance: none;
appearance: none;
border-radius: 4px !important;
outline: none !important;
border: none !important;
}
input[type="radio"].gender{
height: 300px;
width: 170px;
border-radius: 4px !important;
outline: none !important;
border: none !important;
}
As noted in the comments, the :after and :before pseudo elements are inserted inside of the element that they are applied on. :after and :before shouldn't work with inputs as the <input> element cannot have children :(
The solution is to apply the images and :after pseudo element to the radio inputs label. From a semantics point of view it's also nice to give the label a value.
The radio inputs are hidden with display: none and they are selected via their corresponding label attached with the matching for and id attributes.
input + label targets only the label element directly after each input.
input + label:after and input:checked + label:after provide the selected opaque overlay and transition animation
Have an example!
HTML
<div id="welcome-gender">
<input class="male" name="gender" type="radio" value="male" id="male-one">
<label for="male-one">Male One</label>
<input class="female" name="gender" type="radio" value="female" id="female-one">
<label for="female-one">Female One</label>
</div>
CSS
input[type="radio"]{
display: none;
}
label {
position: relative;
width: 170px;
height: 300px;
display: inline-block;
color: white;
font-size: 0;
border-radius: 4px;
}
.male + label {
background: url(http://socialavatarnetworkscript.com/media/img/male_avatar.png);
}
.female + label {
background: url(http://socialavatarnetworkscript.com/media/img/female_avatar.png)
}
input + label:after {
background: #FFF;
content: '';
}
input:checked + label:after {
background: rgba(0, 0, 0, 0.8);
position: absolute;
width: 170px;
height: 300px;
display: block;
content: 'SELECTED';
border-radius: 4px;
color: white;
font-family: titillium, sans-serif;
font-weight: 500;
font-size: 22px;
text-align: center;
line-height: 300px;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-ms-transition: all 0.2s ease;
-o-transition: all 0.2s ease;
transition: all 0.2s ease;
}