Created
May 20, 2020 13:21
-
-
Save ankedsgn/9a677f4b56079d84b31509bb576450d3 to your computer and use it in GitHub Desktop.
FAQ met openklappers en fade in
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function ($) { | |
// faq | |
$('.faq-question').on('click', function(e){ | |
e.preventDefault(); | |
var thisfaq = $(this).parent('.faq-set'); | |
var faqQ = $(this); | |
var faqA = $(this).next('.faq-answer'); | |
if(thisfaq.hasClass('shown')){ | |
thisfaq.removeClass('shown'); | |
faqQ.attr('aria-expanded', false); | |
faqA.attr('aria-hidden', true); | |
} else { | |
thisfaq.addClass('shown'); | |
faqQ.attr('aria-expanded', true); | |
faqA.attr('aria-hidden', false); | |
} | |
}); | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.faq-set { | |
} | |
p.faq-question { | |
font-weight: bold; | |
cursor: pointer; | |
margin-left: 1.7em; | |
text-indent: -1.7em; | |
&:before { | |
content: "+"; | |
display: inline-block; | |
width: 1.2em; | |
height: 1.2em; | |
border-radius: 50%; | |
margin-right: .5em; | |
background-color: var(--freedomPink-dark); | |
color: var(--white); | |
font-weight: normal; | |
text-align: center; | |
line-height: 1.1; | |
text-indent: 0; | |
} | |
.shown & { | |
margin-bottom: var(--vertSpace-xsm); | |
&:before { | |
content: "-"; | |
} | |
} | |
} | |
.faq-answer { | |
display: none; | |
@include respond-to(small-screens){ | |
padding-left: 1.7em; | |
} | |
.shown & { | |
display: block; | |
animation: .5s fadeIn; | |
} | |
} | |
//simple animation | |
@keyframes fadeIn { | |
0% { | |
opacity: 0; | |
} | |
100% { | |
opacity: 1; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- {{ item.block }} --> | |
<div class="faq-set user-content"> | |
<p class="faq-question" role="button" tabindex=0 aria-expanded="false">{{ item.faq_question }}</p> | |
<div class="faq-answer" aria-hidden="true">{{ item.faq_answer|raw }}</div> | |
</div> | |
<!-- /{{ item.block }} --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment