Skip to content

Instantly share code, notes, and snippets.

@eelyafi
Forked from tyv/dabblet.css
Created June 21, 2012 14:51
Show Gist options
  • Save eelyafi/2966197 to your computer and use it in GitHub Desktop.
Save eelyafi/2966197 to your computer and use it in GitHub Desktop.
по состоянию checked включать/выключать
div
{
font-family: Arial, sans-serif;
font-size: 20px;
margin: 1em;
}
.red
{
background: red;
}
.green
{
background: green;
}
.blue
{
background: blue;
}
div span
{
border-radius: 5px;
display: inline-block;
padding: 0 0.15em
}
div label
{
display: inline-block;
text-decoration: underline;
margin-right: 20px;
cursor: pointer;
}
label[for="red"]
{
color: red;
}
label[for="green"]
{
color: green;
}
label[for="blue"]
{
color: blue;
}
/*
по состоянию checked включать/выключать
соответствующие элементы
http://clck.ru/d/Jxj_mgDC143fZ
*/
div input
{
position: absolute;
left: -999px;
}
#red:checked ~ .red,
#green:checked ~ .green,
#blue:checked ~ .blue
{
display: none;
}
#red:not(:checked) ~ label[for="red"],
#green:not(:checked) ~ label[for="green"],
#blue:not(:checked) ~ label[for="blue"]
{
opacity: 0.7;
}
<form>
<div>
<input type="checkbox" id="red">
<input type="checkbox" id="green">
<input type="checkbox" id="blue">
<label for="red">красные</label>
<label for="green">зеленые</label>
<label for="blue">синие</label>
<span class="red">красные</span>
<span class="green">зеленые</span>
<span class="green">зеленые</span>
<span class="red">красные</span>
<span class="blue">синие</span>
<span class="green">зеленые</span>
<span class="red">красные</span>
<span class="blue">синие</span>
<span class="red">красные</span>
<span class="green">зеленые</span>
<span class="blue">синие</span>
</div>
</form>
{"view":"separate","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment