I have this accordion and I am wondering how I could make it 100% width and responsive. I have played around with width attributes and display attributes and it either breaks it or doesn't do anything.
https://jsfiddle.net/5n4ekqdy/
<div class="accordion horizontal">
<ul>
<li>
<input type="radio" id="vert-1" name="vert-accordion" checked="checked" />
<label for="vert-1"><img src="https://teeter.com/wp-content/uploads/2017/10/icon-delivery-1.png"></label>
<div class="content">
<h3>Free Shipping</h3>
</div>
</li>
<li>
<input type="radio" id="vert-2" name="vert-accordion" />
<label for="vert-2"><img src="https://teeter.com/wp-content/uploads/2017/10/icon-delivery-1.png"></label>
<div class="content">
<h3>Free Shipping</h3>
</div>
</li>
<li>
<input type="radio" id="vert-3" name="vert-accordion" />
<label for="vert-3"><img src="https://teeter.com/wp-content/uploads/2017/10/icon-delivery-1.png"></label>
<div class="content">
<h3>Free Shipping</h3>
</div>
</li>
<li>
<input type="radio" id="vert-4" name="vert-accordion" />
<label for="vert-4"><img src="https://teeter.com/wp-content/uploads/2017/10/icon-delivery-1.png"></label>
<div class="content">
<h3>Free Shipping</h3>
</div>
</li>
</ul>
</div>
Your li are what gives the most width to your accordion. You only need one change then to get your desired result.
Change the width of div.content when the radio is checked to be a calculation of 100% of the Viewer Width - minus the width of each label - minus the width of visible padding and borders.
Like so: width: calc(100vw - 316px)
If you change the padding/border/image width, you would have to change this accordingly.
By the way, I love the accordion animation in pure css. Sweet!
body {
margin: 0;
padding: 0;
}
.accordion {
margin:0 auto;
font-size:14px;
width:100%;
padding:0px;
background:#fff;
}
.accordion ul {
list-style:none;
margin:0;
padding:0;
}
.accordion li {
margin:0;
padding:0;
}
.accordion [type=radio], .accordion [type=checkbox] {
display:none;
}
.accordion label {
display: block;
font-size: 16px;
line-height: 16px;
background: #00425f;
color: #ffffff;
font-weight: 400;
cursor: pointer;
text-transform: uppercase;
-webkit-transition: all .2s ease-out;
-moz-transition: all .2s ease-out;
}
.accordion ul li label:hover, .accordion [type=radio]:checked ~ label, .accordion [type=checkbox]:checked ~ label {
background: #005073;
color: #FFF;
}
.accordion .content {
padding: 0 10px;
overflow: hidden;
border: 1px solid #fff;
-webkit-transition: all .5s ease-out;
-moz-transition: all .5s ease-out;
}
.accordion p {
color:#333;
margin:0 0 10px;
}
.accordion h3 {
color: #ffffff;
padding: 0;
margin: 10px 0;
}
/* Horizontal */
/* Unfortunately fixed heights need to be set for this */
.horizontal {
overflow:hidden;
height:49px;
}
.horizontal ul li {
float:left;
margin:0 1px 0 0;
}
.horizontal ul li label {
text-align: center;
height: 49px;
padding: 5px;
width: 60px;
float: left;
}
.horizontal ul li .content {
height: 49px;
padding: 0;
display: inline-block;
visibility: hidden;
width: 1px;
border-left: 0;
}
.horizontal [type=radio]:checked ~ label {
border-right:0;
}
.horizontal ul li label:hover {
//border:1px solid #005073; /* Again, we don't want the border to disappear on hover */
}
.horizontal [type=radio]:checked ~ label ~ .content {
visibility: visible;
/* HERE IS THE CHANGE */
width: calc(100vw - 316px);
padding: 0 10px;
border: 1px solid #005073;
border-left: 0;
background: #005073;
}
<div class="accordion horizontal">
<ul>
<li>
<input type="radio" id="vert-1" name="vert-accordion" checked="checked" />
<label for="vert-1"><img src="https://teeter.com/wp-content/uploads/2017/10/icon-delivery-1.png"></label>
<div class="content">
<h3>Free Shipping</h3>
</div>
</li>
<li>
<input type="radio" id="vert-2" name="vert-accordion" />
<label for="vert-2"><img src="https://teeter.com/wp-content/uploads/2017/10/icon-delivery-1.png"></label>
<div class="content">
<h3>Free Shipping</h3>
</div>
</li>
<li>
<input type="radio" id="vert-3" name="vert-accordion" />
<label for="vert-3"><img src="https://teeter.com/wp-content/uploads/2017/10/icon-delivery-1.png"></label>
<div class="content">
<h3>Free Shipping</h3>
</div>
</li>
<li>
<input type="radio" id="vert-4" name="vert-accordion" />
<label for="vert-4"><img src="https://teeter.com/wp-content/uploads/2017/10/icon-delivery-1.png"></label>
<div class="content">
<h3>Free Shipping</h3>
</div>
</li>
</ul>
</div>
Related
I have a question:
I want my radio button at default-mode to have the css:
border-color: #00AD51;
color: #fff;
background-color: #00AD51;
and when the user selects/clicks on another radio button it changes to this css:
border-color: #00AD51;
color: #00AD51;
background-color: #fff;
Is this possible? How can I make specific css on default-mode and checked-mode on radio buttons?
HTML:
<p><b>What is your favorite animal?</b></p><br />
<div class="Animals"><div class="input">
<input id="dog" type="radio" name="Animal" checked>
<label for="dog"><span>Dog</span></label>
</div>
<div class="Animals"><div class="input">
<input id="cat" type="radio" name="Animal">
<label for="cat"><span>Cat</span></label>
</div>
<div class="Animals"><div class="input">
<input id="Horse" type="radio" name="Animal">
<label for="Horse"><span>Horse</span></label>
</div>
<div class="Animals"><div class="input">
<input id="Cow" type="radio" name="Animal">
<label for="Cow"><span>Cow</span></label>
</div>
Link to codepen: https://codepen.io/vicm/pen/QBPQWZ
Here is a snippet where I:
Added the closing </div> in your HTML,
Reorganized your CSS code and tried to remove duplicate styled properties,
Corrected some typo errors (display: inline-blok to display: inline-block, position:relavitve; to position: relative; …),
I added some styling plus comments to make things clear about the different possible states,
Instead of using checked on the "recommended" answer, you can use another custom property, like "recommend", and use it in your CSS to stylize it correctly.
input[type=radio] {
margin-right: 3px;
position: relative;
top: 3px;
}
.Animals {
display: inline-block;
height: 100px;
margin: 10px;
border: 2px solid #003D6A;
border-radius: 3px;
background-color: #fff;
padding: 10px;
text-align: center;
line-height: 20px;
font-family: Helvetica;
font-size: 20px;
}
.Animals .input {
padding-bottom: 0;
}
.Animals input[type=radio] {
opacity: 0;
}
.Animals input[type=radio]+label {
cursor: pointer;
text-shadow: 1px 1px 0 rgba(0, 0, 0, 0);
border: 2px solid;
margin: 10px;
height: 100px;
border-radius: 3px;
text-align: center;
font-size: 20px;
font-family: Helvetica;
width: 292px;
/* Default */
border-color: darkblue;
background-color: #fff;
color: darkblue;
}
/* Recommanded */
.Animals input[type=radio][recommand]+label {
border-color: turquoise;
color: turquoise;
}
/* Hover */
.Animals input[type=radio]+label:hover {
border-color: #00AD51;
color: #00AD51;
}
/* Checked */
.Animals input[type=radio]:checked+label {
border-color: #00AD51;
background-color: #00AD51;
color: #fff;
}
.Animals label span {
position: relative;
top: 33%;
}
<p><b>What is your favorite animal?</b></p><br />
<div class="Animals">
<div class="input">
<input id="dog" type="radio" name="Animal" recommand>
<label for="dog"><span>Dog</span></label>
</div>
</div>
<div class="Animals">
<div class="input">
<input id="cat" type="radio" name="Animal">
<label for="cat"><span>Cat</span></label>
</div>
</div>
<div class="Animals">
<div class="input">
<input id="Horse" type="radio" name="Animal">
<label for="Horse"><span>Horse</span></label>
</div>
</div>
<div class="Animals">
<div class="input">
<input id="Cow" type="radio" name="Animal">
<label for="Cow"><span>Cow</span></label>
</div>
</div>
If you wish to modify something, it should be easier now.
You can use this simple trick.
When user can click or check the radio button
.Animals input[type=radio]:checked + label{border-color: #00AD51;color: #00AD51;background-color: #fff;}
Hope this help.
Let me know further clarification.
input[type=radio]
{
margin-right: 3px;
position: relative;
top: 3px;
}
.Animals
{
border:2px solid #003D6A;
margin:10px;
height:100px;
padding:10px;
border-radius:3px;
text-align:center;
font-size: 20px;
line-height: 20px;
background-color:#fff;
font-family: Helvetica;
display: inline-blok;
}
.Animals{
margin: 0 auto;
}
.Animals input[type=radio] {
opacity: 0;
position:relavitve;
}
.Animals input[type=radio] + label {
cursor: pointer;
text-shadow: 1px 1px 0 rgba(0,0,0,0);
border: 2px solid #003D6A;
margin: 10px;
height: 100px;
border-radius: 3px;
text-align: center;
font-size: 20px;
font-family: Helvetica;
width: 292px;
background-color: #ffffff;
}
.Animals input[type=radio] + label:hover{
border-color: #00AD51;
background-color: #fff;
color: #00AD51;
}
.Animals .input
{
padding-bottom:0;
}
.Animals label span
{
position:relative;
top:33%;
}
.Animals input[type=radio]:checked + label{
border-color: #00AD51;
color: #00AD51;
background-color: #fff;
}
<p><b>What is your favorite animal?</b></p><br />
<div class="Animals"><div class="input">
<input id="dog" type="radio" name="Animal" checked>
<label for="dog"><span>Dog</span></label>
</div>
<div class="Animals"><div class="input">
<input id="cat" type="radio" name="Animal">
<label for="cat"><span>Cat</span></label>
</div>
<div class="Animals"><div class="input">
<input id="Horse" type="radio" name="Animal">
<label for="Horse"><span>Horse</span></label>
</div>
<div class="Animals"><div class="input">
<input id="Cow" type="radio" name="Animal">
<label for="Cow"><span>Cow</span></label>
</div>
I have a problem and this isn't really my area and am not able to find a good solution, please help me. I want to make my slider on my website responsive. Do you have any idea how I should do it?
The slider needs to be smaller or be shaped differently when I make the window smaller. Can I use the #media rule or is it something else I should do?
Thanx for helping a beginner like me:)!
<ul class="slides">
<input type="radio" name="radio-btn" id="img-1" checked />
<li class="slide-container">
<div class="slide">
<img src="bilder/blommor.jpg" />
</div>
<div class="nav">
<label for="img-6" class="prev">‹</label>
<label for="img-2" class="next">›</label>
</div>
</li>
<input type="radio" name="radio-btn" id="img-2" />
<li class="slide-container">
<div class="slide">
<img src="bilder/Berg.jpg" />
</div>
<div class="nav">
<label for="img-1" class="prev">‹</label>
<label for="img-3" class="next">›</label>
</div>
</li>
<input type="radio" name="radio-btn" id="img-3" />
<li class="slide-container">
<div class="slide">
<img src="bilder/water.jpg" />
</div>
<div class="nav">
<label for="img-2" class="prev">‹</label>
<label for="img-4" class="next">›</label>
</div>
</li>
<input type="radio" name="radio-btn" id="img-4" />
<li class="slide-container">
<div class="slide">
<img src="bilder/ros.jpg" />
</div>
<div class="nav">
<label for="img-3" class="prev">‹</label>
<label for="img-5" class="next">›</label>
</div>
</li>
<input type="radio" name="radio-btn" id="img-5" />
<li class="slide-container">
<div class="slide">
<img src="bilder/glasogon.jpg" />
</div>
<div class="nav">
<label for="img-4" class="prev">‹</label>
<label for="img-6" class="next">›</label>
</div>
</li>
<li class="nav-dots">
<label for="img-1" class="nav-dot" id="img-dot-1"></label>
<label for="img-2" class="nav-dot" id="img-dot-2"></label>
<label for="img-3" class="nav-dot" id="img-dot-3"></label>
<label for="img-4" class="nav-dot" id="img-dot-4"></label>
<label for="img-5" class="nav-dot" id="img-dot-5"></label>
</li>
Css:
#import url(https://fonts.googleapis.com/css?family=Varela+Round);
html, body { background: #333 url("https://codepen.io/images/classy_fabric.png"); }
.slides {
padding: 0;
width: 609px;
height: 420px;
display: block;
margin: 0 auto;
position: relative;
}
.slides * {
user-select: none;
-ms-user-select: none;
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
-webkit-touch-callout: none;
}
.slides input { display: none; }
.slide-container { display: block; }
.slide {
top: 0;
opacity: 0;
width: 609px;
height: 420px;
display: block;
position: absolute;
transform: scale(0);
transition: all .7s ease-in-out;
}
.slide img {
width: 100%;
height: 100%;
}
.nav label {
width: 200px;
height: 100%;
display: none;
position: absolute;
opacity: 0;
z-index: 9;
cursor: pointer;
transition: opacity .2s;
color: #FFF;
font-size: 156pt;
text-align: center;
line-height: 380px;
font-family: "Varela Round", sans-serif;
background-color: rgba(255, 255, 255, .3);
text-shadow: 0px 0px 15px rgb(119, 119, 119);
}
.slide:hover + .nav label { opacity: 0.5; }
.nav label:hover { opacity: 1; }
.nav .next { right: 0; }
input:checked + .slide-container .slide {
opacity: 1;
transform: scale(1);
transition: opacity 1s ease-in-out;
}
input:checked + .slide-container .nav label { display: block; }
.nav-dots {
width: 100%;
bottom: 9px;
height: 11px;
display: block;
position: absolute;
text-align: center;
}
.nav-dots .nav-dot {
top: -5px;
width: 11px;
height: 11px;
margin: 0 4px;
position: relative;
border-radius: 100%;
display: inline-block;
background-color: rgba(0, 0, 0, 0.6);
}
.nav-dots .nav-dot:hover {
cursor: pointer;
background-color: rgba(0, 0, 0, 0.8);
}
input#img-1:checked ~ .nav-dots label#img-dot-1,
input#img-2:checked ~ .nav-dots label#img-dot-2,
input#img-3:checked ~ .nav-dots label#img-dot-3,
input#img-4:checked ~ .nav-dots label#img-dot-4,
input#img-5:checked ~ .nav-dots label#img-dot-5,
input#img-6:checked ~ .nav-dots label#img-dot-6 {
background: rgba(0, 0, 0, 0.8);
}
I found the pure CSS Tabs that I want to to use in my WordPress posts in https://webdesignerhut.com/examples/pure-css-tabs/.
when I use in my post, it looks messy:
example
I used this HTML code into Wordpress text editor:
.tabs {
max-width: 90%;
float: none;
list-style: none;
padding: 0;
margin: 75px auto;
border-bottom: 4px solid #ccc;
}
.tabs:after {
content: '';
display: table;
clear: both;
}
.tabs input[type=radio] {
display:none;
}
.tabs label {
display: block;
float: left;
width: 33.3333%;
color: #ccc;
font-size: 30px;
font-weight: normal;
text-decoration: none;
text-align: center;
line-height: 2;
cursor: pointer;
box-shadow: inset 0 4px #ccc;
border-bottom: 4px solid #ccc;
-webkit-transition: all 0.5s; /* Safari 3.1 to 6.0 */
transition: all 0.5s;
}
.tabs label span {
display: none;
}
.tabs label i {
padding: 5px;
margin-right: 0;
}
.tabs label:hover {
color: #3498db;
box-shadow: inset 0 4px #3498db;
border-bottom: 4px solid #3498db;
}
.tab-content {
display: none;
width: 100%;
float: left;
padding: 15px;
box-sizing: border-box;
background-color:#ffffff;
}
.tab-content * {
-webkit-animation: scale 0.7s ease-in-out;
-moz-animation: scale 0.7s ease-in-out;
animation: scale 0.7s ease-in-out;
}
#keyframes scale {
0% {
transform: scale(0.9);
opacity: 0;
}
50% {
transform: scale(1.01);
opacity: 0.5;
}
100% {
transform: scale(1);
opacity: 1;
}
}
.tabs [id^="tab"]:checked + label {
background: #FFF;
box-shadow: inset 0 4px #3498db;
border-bottom: 4px solid #3498db;
color: #3498db;
}
#tab1:checked ~ #tab-content1,
#tab2:checked ~ #tab-content2,
#tab3:checked ~ #tab-content3 {
display: block;
}
#media (min-width: 768px) {
.tabs i {
padding: 5px;
margin-right: 10px;
}
.tabs label span {
display: inline-block;
}
.tabs {
margin: 50px auto;
}
}
<div class="tabs">
<!-- Radio button and lable for #tab-content1 -->
<input type="radio" name="tabs" id="tab1" checked >
<label for="tab1">
<i class="fa fa-html5"></i><span>Tab-1</span>
</label>
<!-- Radio button and lable for #tab-content2 -->
<input type="radio" name="tabs" id="tab2">
<label for="tab2">
<i class="fa fa-css3"></i><span>Tab-2</span>
</label>
<!-- Radio button and lable for #tab-content3 -->
<input type="radio" name="tabs" id="tab3">
<label for="tab3">
<i class="fa fa-code"></i><span>Tab-3</span>
</label>
<div id="tab-content1" class="tab-content">
<h3>Tab-1 Title</h3>
<p>Tab-1 Content</p>
</div> <!-- #tab-content1 -->
<div id="tab-content2" class="tab-content">
<h3>Tab-2 Title</h3>
<p>Tab-2 Content</p>
</div> <!-- #tab-content2 -->
<div id="tab-content3" class="tab-content">
<h3>Tab-3 Title</h3>
<p>Tab-3 Content</p>
</div> <!-- #tab-content3 -->
</div>
what's wrong here?
I think your wordpress theme already contain the class name is tab so use the different class
just rename the tabs into tabs-s
and tab into tab-s
It may solve your problem try this..
use like below code:
<html>
<head>
<title> </title>
<style>
.tabs-s {
max-width: 90%;
float: none;
list-style: none;
padding: 0;
margin: 75px auto;
border-bottom: 4px solid #ccc;
}
.tabs-s:after {
content: '';
display: table;
clear: both;
}
.tabs-s input[type=radio] {
display:none;
}
.tabs-s label {
display: block;
float: left;
width: 33.3333%;
color: #ccc;
font-size: 30px;
font-weight: normal;
text-decoration: none;
text-align: center;
line-height: 2;
cursor: pointer;
box-shadow: inset 0 4px #ccc;
border-bottom: 4px solid #ccc;
-webkit-transition: all 0.5s; /* Safari 3.1 to 6.0 */
transition: all 0.5s;
}
.tabs-s label span {
display: none;
}
.tabs-s label i {
padding: 5px;
margin-right: 0;
}
.tabs-s label:hover {
color: #3498db;
box-shadow: inset 0 4px #3498db;
border-bottom: 4px solid #3498db;
}
.tab-content {
display: none;
width: 100%;
float: left;
padding: 15px;
box-sizing: border-box;
background-color:#ffffff;
}
.tab-content * {
-webkit-animation: scale 0.7s ease-in-out;
-moz-animation: scale 0.7s ease-in-out;
animation: scale 0.7s ease-in-out;
}
#keyframes scale {
0% {
transform: scale(0.9);
opacity: 0;
}
50% {
transform: scale(1.01);
opacity: 0.5;
}
100% {
transform: scale(1);
opacity: 1;
}
}
.tabs-s [id^="tab"]:checked + label {
background: #FFF;
box-shadow: inset 0 4px #3498db;
border-bottom: 4px solid #3498db;
color: #3498db;
}
#tab1:checked ~ #tab-content1,
#tab2:checked ~ #tab-content2,
#tab3:checked ~ #tab-content3 {
display: block;
}
#media (min-width: 768px) {
.tabs-s i {
padding: 5px;
margin-right: 10px;
}
.tabs-s label span {
display: inline-block;
}
.tabs-s {
margin: 50px auto;
}
}
</style>
</head>
<body>
<div class="tabs-s">
<!-- Radio button and lable for #tab-content1 -->
<input type="radio" name="tabs-s" id="tab1" checked >
<label for="tab1">
<i class="fa fa-html5"></i><span>Tab-1</span>
</label>
<!-- Radio button and lable for #tab-content2 -->
<input type="radio" name="tabs-s" id="tab2">
<label for="tab2">
<i class="fa fa-css3"></i><span>Tab-2</span>
</label>
<!-- Radio button and lable for #tab-content3 -->
<input type="radio" name="tabs-s" id="tab3">
<label for="tab3">
<i class="fa fa-code"></i><span>Tab-3</span>
</label>
<div id="tab-content1" class="tab-content">
<h3>Tab-1 Title</h3>
<p>Tab-1 Content</p>
</div> <!-- #tab-content1 -->
<div id="tab-content2" class="tab-content">
<h3>Tab-2 Title</h3>
<p>Tab-2 Content</p>
</div> <!-- #tab-content2 -->
<div id="tab-content3" class="tab-content">
<h3>Tab-3 Title</h3>
<p>Tab-3 Content</p>
</div> <!-- #tab-content3 -->
</div>
</body>
</html>
Happy coding :)
I have a form, that may have 3 or 5 labels with input types (depending on some config elsewhere).
I have a border around this form, with fixed height and width. When the number of input types is 3, the form should be little bit smaller, and when the input types is 5, should be a little bit bigger, to accommodate the extra fields.
I would also like the text to be on the lhs, and aligned.
/* code to reset the browser - compliments to meyerweb */
* {
margin: 0;
padding: 0;
border: 0;
font-size: 10px;
font: inherit;
vertical-align: baseline;
}
.loginform {
padding-top: 20px;
padding-left: 20px;
width: auto;
height:auto;
border: 1px solid #999;
border: inset 1px solid #333;
border-size: auto;
border-radius: 10px;
margin: 10px 300px;
margin-top: 45px;
font-family: Tahoma;
font-size: 12px;
}
.loginform ul {
margin: 0;
}
.loginform li {
display:block;
float:left;
clear: left;
width:auto;
height:15px;
padding: 10px;
}
.loginform li label{
display: inline-block;
width: 25%; /* giving the label a width, makes sure the input boxes align */
}
<section class="loginform">
<form method="POST" autocomplete="off">
<ul>
<li>
<input type="text" >One</input>
</li>
<li>
<input type="text" >Two</input>
</li>
<li>
<input type="text" >Three</input>
</li>
</ul>
</form>
</section>
The border does not control the size of the element so perhaps your understanding of what the border does is incorrect or you are using the work "border" when perhaps you mean "container".
A border is a decoration which sits on the outside edges of the element..it does not define the size of the element.
That being the case, I think the property you are looking for is display:inline-block:
.loginform {
padding:20px;
display: inline-block;
vertical-align: top;
background: lightblue;
border: 1px solid #999;
border-radius: 10px;
margin: 10px auto;
font-family: Tahoma;
font-size: 12px;
}
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
}
.loginform {
padding: 20px;
display: inline-block;
vertical-align: top;
background: lightblue;
border: 1px solid #999;
border-radius: 10px;
margin: 10px auto;
font-family: Tahoma;
font-size: 12px;
}
ul {
list-style-type: none;
}
<section class="loginform">
<form method="POST" autocomplete="off">
<ul>
<li>
<input type="text">One</input>
</li>
<li>
<input type="text">Two</input>
</li>
<li>
<input type="text">Three</input>
</li>
</ul>
</form>
</section>
<section class="loginform">
<form method="POST" autocomplete="off">
<ul>
<li>
<input type="text">One</input>
</li>
<li>
<input type="text">Two</input>
</li>
<li>
<input type="text">Three</input>
</li>
<li>
<input type="text">Four</input>
</li>
<li>
<input type="text">Five</input>
</li>
</ul>
</form>
</section>
I wanna change color for each checkbox while hover.I have four checkbox.I wanna change the color, If I hover the 'all' checkbox it shows red,blue color for 'cold',orange for 'warm' and green for 'Active'.
#ck-button {
margin: 0px;
background-color: #EFEFEF;
border-radius: 4px;
border: 1px solid #D0D0D0;
overflow: auto;
float: left;
}
#ck-button label {
float: left;
width: 4.0em;
}
#ck-button label span {
text-align: center;
padding: 3px 0px;
display: block;
border-radius: 4px;
}
#ck-button label input {
position: absolute;
top: -20px;
}
input:checked +span {
background-color: #911;
color: #fff;
}
#ck-button input:hover #all + span {
background-color: #efE0E0;
}
#ck-button input:hover #o1 + span {
background-color: blue;
}
#ck-button input:hover #o2 + span {
background-color: orange;
}
#ck-button input:hover #o3 + span {
background-color: green;
}
<div id="ck-button">
<label>
<input type="radio" name="sta_choice" id=all value="All" checked><span>All</span>
</label>
</div>
<div id="ck-button">
<label>
<input type="radio" name="sta_choice" id="o1" value="Cold" onclick=handleClick1(this.val);><span class="o1">Cold</span>
</label>
</div>
<div id="ck-button">
<label>
<input type="radio" name="sta_choice" id="o2" value="Warm" onclick="handleClick1(this.val);"><span>Warm</span>
</label>
</div>
<div id="ck-button">
<label>
<input type="radio" name="sta_choice" id="o3" value="Active" onclick="handleClick1(this.val);"><span>Active</span>
</label>
</div>
In the last four lines use label:hover instead of input:hover. Input is positioned to top and isn't hovered (is outside the label).
#ck-button label:hover #all + span {
background-color:#efE0E0;
}
#ck-button label:hover #o1 + span {
background-color:blue;
}
#ck-button label:hover #o2 + span {
background-color:orange;
}
#ck-button label:hover #o3 + span {
background-color:green;
}
http://jsfiddle.net/3q4uuvum/3/
even as an option
*{
padding: 0;
margin: 0;
box-sizing: border-box;
}
ul{
text-align: center;
width: 300px;
margin: 25px auto;
}
ul > li{
display: inline-block;
*display: inline;
zoom: 1;
vertical-align: top;
width: 100px;
height: 100px;
border: 1px solid #ccc;
position: relative;
}
input{
display: none;
}
label{
display: block;
width: 100px;
height: 100px;
}
label:hover{
background: #f7f7f7;
}
input:checked ~ label{
position: absolute; top: 0; left: 0;
width: 100%;
height: 100%;
background: url(http://html5doctor.com/wp-content/themes/html5doctor2/images/HTML5_Badge_64.png) no-repeat center center;
border: 1px solid #000;
}
<ul>
<li>
<input type="checkbox" id="c1" name="checkbox" />
<label for="c1"></label>
<li>
<input type="checkbox" id="c2" name="checkbox" />
<label for="c2"></label>
<li>
<input type="checkbox" id="c3" name="checkbox" />
<label for="c3"></label>
<li>
<input type="checkbox" id="c4" name="checkbox" checked />
<label for="c4"></label>
<li>
<input type="checkbox" id="c5" name="checkbox" />
<label for="c5"></label>
<li>
<input type="checkbox" id="c6" name="checkbox" />
<label for="c6"></label>
<li>
<input type="checkbox" id="c7" name="checkbox" />
<label for="c7"></label>
<li>
<input type="checkbox" id="c8" name="checkbox" />
<label for="c8"></label>
<li>
<input type="checkbox" id="c9" name="checkbox" />
<label for="c9"></label>
</ul>
I couldn't find online how to display different colors for hover depending if the box is checked, but after tirelessly tweaking the code I figured it out.
.ck-button-class:hover input:checked + span {
background-color: green;
}
This is assuming you assigned the class to these buttons, <div id="ck-button" class="ck-button-class">.