0

I am using twitter bootstrap and the transition.js plugin to make a collapse like described here.

http://getbootstrap.com/javascript/#collapse

I have two problems with it:

  1. How can i remove the animation from the effect? it should instantly open and close.

  2. How can i give the open panel a different background color?

clamp
  • 33,000
  • 75
  • 203
  • 299

1 Answers1

3

To remove the animation effect you need to override the .collapsing class, add this to your CSS:

.collapsing{
    -webkit-transition: none;
          transition: none;
}

Now, to style the active panel you'd need to implement some jQuery code to add a custom class when a panel is shown since by default only the panel-body container is marked with the in class, and you wouldn't be able to target the heading with that. Something like this should work:

$('#accordion').on('show.bs.collapse','.panel-collapse',function(e){
    $(this).closest('.panel').addClass('active').siblings('.panel').removeClass('active');
});

Then you can add your CSS rules as:

#accordion .active .panel-heading{
    background: darkgrey;
}

#accordion .active .panel-body{
    background: #ccc;
}

Here's a working demo

*Note: don't forget to add the "active" class to the pane that is open by default (if any)

omma2289
  • 54,161
  • 8
  • 64
  • 68