I've come across forums where spoilers are hidden behind toggle buttons instead of just being visible text.
It's a neat feature that allows users to reveal the content only if they choose to do so.
I'm considering adding a hidden section to my website to conserve space.
https://jsfiddle.net/clarle/bY7m4/
This solution seems to fit my requirements perfectly.
HTML
<div class="forum-post">
<a href="#hide" class="hide btn" id="hide">Show spoiler</a>
<a href="#show" class="show btn" id="show">Hide spoiler</a>
<div class="spoiler">
<p class="spoiler-content">People die when they are killed!</p>
</div>
</div>
CSS
.spoiler {
display: none;
}
.show {
display: none;
}
.hide:target + .show {
display: inline;
}
.hide:target {
display: none;
}
.hide:target ~ .spoiler {
display: inline;
}
/* Additional CSS styles for aesthetics */
body {
margin: 0;
padding: 20px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
line-height: 20px;
color: #333333;
background-color: #FFFFFF;
}
.btn {
// Styling properties...
}
.forum-post {
padding: 20px;
border: 1px solid #000;
}
.spoiler-content {
padding: 15px;
}