Ryan Seddon
Stateful CSS, makes for something unexpected be extremely powerful
Original demo by Simurai
<input type="radio" name="opts" id="opts1"> <label for="opts1">Option</label>
Setup the styles to react to label clicks
input + label { background-position: 50px 0; } input:checked + label { background-position: 0 0; } input:checked ~ input + label { background-position: -50px 0; }
input + label { /* less interesting styles */ background-image: radial-gradient(hsla(200, 100%, 90%, 1) 0%, hsla(200, 100%, 70%, 1) 15%, hsla(200, 100%, 60%, 0.3) 28%, hsla(200, 100%, 30%, 0) 70%); border-radius: 25px; box-shadow: hsla(0, 0%, 100%, 0.15) 0 1px 1px, inset hsla(0, 0%, 0%, 0.5) 0 0 0 1px; transition: background-position 0.15s cubic-bezier(0.8, 0, 1, 1); }
<ol> <li> <input type="checkbox" checked id="folder1" /> <label for="folder1" onclick>Folder 1</label> <ol> <li>File</li> </ol> </li> ... more items </ol>
.tree li input:checked ~ ol { height: auto; padding: 0 0 0 35px; } .tree li label:after, .tree li label:before, .tree li input:checked ~ ol:before { background: url(icon-sprite.png) 0 0 no-repeat; content: ""; height: 14px; width: 14px; } .tree li input ~ ol > li { display: none; } .tree li input:checked ~ ol > li { display: block; }
Or go to github and checkout the source code.
<input type="checkbox" id="foo"> <label onclick="" for="foo">I need an onclick in iOS</label>
<=iOS5 will not update a checkboxes state when touching a label, but adding an onclick attribute works.
Confusing markup when consumed through a screenreader
* and by sometimes I mean most of the time...
Look at the Carousel CSS +/~ all over