Pure CSS3 Spoiler 2 — with label inner text
by denvdmj
HTML
<h1>Pure CSS3 Spoiler 2 — with label inner text</h1>
<input type="checkbox" id="spoiler:1" />
<label for="spoiler:1">
<span>Show</span>
<span>Hide</span>
lorem ipsum dolor</label>
<div spoiler>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</div>
CSS
body {
font: 15px/1.4 Arial, sans-serif;
padding: 1em 2em;
margin: auto;
max-width: 50em;
min-width: 20em;
background: #fff;
}
input[id^="spoiler:"] {
display: none;
}
input[id^="spoiler:"] + label {
cursor: pointer;
color: #009;
}
input[id^="spoiler:"]:checked + label > :nth-child(1) {
display: none;
}
input[id^="spoiler:"]:checked + label > :nth-child(2) {
display: inline;
}
input[id^="spoiler:"] + label > :nth-child(2) {
display: none;
}
input[id^="spoiler:"]:checked + label {
color: #900;
}
input[id^="spoiler:"] + label:hover {
text-decoration: underline;
}
[spoiler] {
display: none;
}
input[id^="spoiler:"]:checked + label + [spoiler] {
display: block;
}