click on the header to show or hide the answer
<div class="demo-wrap">
<div id="demo-header" class="demo-header">
What does the word “mare” in 'nightmare' mean?
</div>
<div id="demo-content" class="demo-content">
<div class="demo-content-text">
The word “mare” refers to a female goblin
that sits on you, suffocates you while you
sleep, entangles her hair around you,
and tries to induce bad thoughts.
</div>
</div>
<div class="demo-content-subtext">
<p><i class="fa-solid fa-person-circle-question fa-4x"></i></p>
<p>click on the header to show or hide the answer</p>
</div>
</div>
.demo-wrap {
margin: 0 auto;
width: 600px;
position: relative;
border: 1px solid #ECECEC;
border-radius: 6px;
}
.demo-content {
display: none;
background: #f0f0f0;
position: absolute;
z-index: 1;
width: 100%;
}
.demo-content-text {
padding: 1em;
}
.demo-content-subtext {
padding: 0.5em 1em;
text-align: center;
}
.demo-header {
padding: 10px 20px;
background-color: #525252;
color: #FFFFFF;
border-top-right-radius: 6px;
border-top-left-radius: 6px;
cursor: pointer;
}
.demo-header::after {
content: "\f0ab";
font-family: FontAwesome;
padding-top: 4px;
color: #FFFFFF;
float: right;
}
.demo-header-close {
padding: 10px 20px;
}
.demo-header-close::after {
content: "\f0aa";
font-family: FontAwesome;
padding-top: 4px;
color: #E5E5E5;
float: right;
}
$(document).ready(function() {
$("#demo-header").click(function() {
$(this).next("#demo-content").slideToggle("slow");
$(this).toggleClass("demo-header-close");
});
});