Usually, this widget is used for an FAQ page or blog landing page which is useful for explaining a basic question from a customer.
Hello TipRicks friends, this time I will share a simple tutorial that can be used for all blogger and WordPress platforms. Of course, my friend is familiar with this one widget, the Accordion, which can display and hide certain content in the form of text, images, and so on.
Usually, this widget is used for an FAQ page or blog landing page which is useful for explaining a basic question from a customer and when the question is clicked it will bring up the answer. The design I provide in this tutorial is simple enough to be suitable for all types of blogs that you use.
This widget is useful for friends who have blogs with service themes or blogs that need to show, hide images/video, or other content.
How to Install an Accordion Widget on a Page/Post
The first step, make sure you have the following on the blog template:
- Font Awesome Version 5
- Jquery
[/* CSS Accordion */.collapse{display:none}#accordion h3{margin:0}.showx .collapse{display:block}.collapse .card-body{padding:10px 25px 40px;color:#555}button.btn.btn-link{display:block;background:#fff;border:none;outline:none;width:100%;margin:10px 0;padding:10px 25px;cursor:pointer;text-transform:none;text-align:left}button.btn.btn-link:before{content:'\f107';font-family:'Font Awesome 5 Free';font-weight:600;font-size:2rem;color:#122949;position:absolute;left:25px;top:15px;opacity:.7;transform:rotate(-90deg);transition:all .3s ease-in-out}.showx button.btn.btn-link:before{transform:rotate(0deg)}.card{background:#fff;box-shadow:0 2px 2px 0 rgba(0,0,0,0.1);border:1px solid #eee;border-radius:5px;position:relative;overflow:hidden;margin:10px 0;padding:0 0 0 40px}.card-header button h4{font-weight:400;color:#122949;font-size:1.1rem;margin:0}#accordion .card-body img{margin:20px auto;border-radius:7px}]
[<script>//<![CDATA[// Accordion FAQ$("#accordion .btn").click(function() {var get_target = $(this).attr("data-target");$(get_target).slideToggle("fast");$(this).parent().parent().toggleClass("showx")}),$(document).ready(function() {var get_target;"true" == $("#accordion .btn").attr("aria-expanded") && (get_target = $(this).attr("data-target"), $(get_target).slideToggle("fast"))});//]]></script>]
[<div id='accordion'><!-- ACORD START --><div class='card showx'><div class='card-header' id='heading1'><button aria-controls='collapse1' aria-expanded='true' class='btn btn-link' data-target='#collapse1' data-toggle='collapse'><h4>What is Blogger?</h4></button></div><div aria-labelledby='heading1' class='collapse' data-parent='#accordion' id='collapse1'><div class='card-body'>Blogger is an American blog-publishing service that allows multi-user blogs with time-stamped entries. It was developed by Pyra Labs, which was bought by Google in 2003. The blogs are hosted by Google and generally accessed from a subdomain of blogspot.com. Blogs can also be served from a custom domain owned by the user (like www.example.com) by using DNS facilities to direct a domain to Google's servers.</div></div></div><!-- ACORD END --><!-- ACORD START --><div class='card'><div class='card-header' id='heading2'><button aria-controls='collapse2' aria-expanded='true' class='btn btn-link' data-target='#collapse2' data-toggle='collapse'><h4>This product have a guarantee?</h4></button></div><div aria-labelledby='heading2' class='collapse' data-parent='#accordion' id='collapse2'><div class='card-body'>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.<center><img alt="Image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyUjwBq-gSQpQW2gEXqmpEGfCjH7cI2lUsucWkfDxvIApeBcOcmkLLPJF0QUEoIxgL31agIy9QAwGfbADEuzxli6Dbri54zPlhvwhfsX0gdlt-jqcTrVXUz_3WzAXY3-uAxsHEwiyubDp-/s600/tipricks-spike-logo-top-ad.png"/></center></div></div></div><!-- ACORD END --><!-- ACORD START --><div class='card'><div class='card-header' id='heading3'><button aria-controls='collapse3' aria-expanded='true' class='btn btn-link' data-target='#collapse3' data-toggle='collapse'><h4>How about the Documentation?</h4></button></div><div aria-labelledby='heading3' class='collapse' data-parent='#accordion' id='collapse3'><div class='card-body'>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</div></div></div><!-- ACORD END --></div>]
This article "Creating Accordion Widgets for Pages and Posts with jQuery" is protected by
COMMENTS