After creating an accordion using jquery
and css
, everything seems to be working fine except for the transition effect when collapsing. The collapse action is too fast, both when opening and closing. I am unable to apply a slower transition effect.
Check out my demo here
Below is the code snippet:
HTML--
<div class="accordiam">
<div class="child_bg">
<h2 class="title_headig"><a href="javascript:void(0)">Lorem ipsum dolor sit amet, consectetur adipisicing elit</a></h2>
<div class="accordiam_body">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat</p>
</div>
</div>
<div class="child_bg">
<h2 class="title_headig"><a href="javascript:void(0)">Lorem ipsum dolor sit amet, consectetur adipisicing elit</a></h2>
<div class="accordiam_body active">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat</p>
</div>
</div>
<div class="child_bg">
<h2 class="title_headig"><a href="javascript:void(0)">Lorem ipsum dolor sit amet, consectetur adipisicing elit</a></h2>
<div class="accordiam_body">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat</p>
</div>
</div>
</div>
CSS--
.accordiam {
width:800px;
}
h2 {
margin:0;
padding: 0;
}
.child_bg {
margin: 1px 0 0 0;
}
.title_headig a {
padding:8px 20px;
background:#999900;
font-size: 18px;
font-family: monospace;
text-decoration: none;
color:#fff;
z-index: 500;
display: block;
position: relative;
margin:0;
line-height: 28px;
}
.accordiam_body {
width:96.6%;
background:#fff;
line-height: 25px;
height:auto;
border: 1px solid #999;
padding:0px 0px 0px 25px;
transition: all .5s;
display:none;
}
.accordiam_body.active {
display: block;
}
JQuery--
$(document).ready(function(){
$(".title_headig a").click(function(){
$(".accordiambody").hide();
$(this).parent().parent().children(".accordiam_body").slideToggle();
});
})