+ 1

Help: How can I make a spoiler with CSS ?

I want to make a spoiler for my website, please help me do it

25th Sep 2016, 3:10 PM
Nightwalker Yao 🇨🇮
Nightwalker Yao 🇨🇮 - avatar
5 Answers
+ 3
HTML: <div class="spoiler"> <input type="checkbox" id="spoilerid_1"> <label for="spoilerid_1">Spoiler header</label> <div class="spoiler_body">Hidden content</div> </div> CSS: .spoiler > input + label:after{content: "+";float: right;font-family: monospace;font-weight: bold;} .spoiler > input:checked + label:after{content: "-";float: right;font-family: monospace;font-weight: bold;} .spoiler > input{display:none;} .spoiler > input + label , .spoiler > .spoiler_body{background:#CCC;padding:5px 15px;overflow:hidden;width:100%;box-sizing: border-box;display: block;} .spoiler > input + label + .spoiler_body{display:none;} .spoiler > input:checked + label + .spoiler_body{display: block;} .spoiler > .spoiler_body{background: #FFF;border: 3px solid #CCC;border-top: none;}
26th Sep 2016, 9:50 PM
Vladimir Honcharenko
Vladimir Honcharenko - avatar
+ 1
Another question, can you give an explanation of the "+" and ">" selectors , please
5th Jan 2017, 9:15 PM
Nightwalker Yao 🇨🇮
Nightwalker Yao 🇨🇮 - avatar
+ 1
div > p - Selects all <p> elements where the parent is a <div> element div + p - Selects all <p> elements that are placed immediately after <div> elements
5th Jan 2017, 9:28 PM
Vladimir Honcharenko
Vladimir Honcharenko - avatar
0
Can you define spoiler?
26th Sep 2016, 9:08 PM
Niels Vandewinkel
Niels Vandewinkel - avatar
0
thanks you! it works perfect!
9th Oct 2016, 2:00 AM
Nightwalker Yao 🇨🇮
Nightwalker Yao 🇨🇮 - avatar