Adding open/closed icon to Twitter Bootstrap collapsibles (accordions)

后端 未结 19 2450
失恋的感觉
失恋的感觉 2020-12-22 18:23

I\'ve set up this simple version of the Bootstrap accordion:

Simple accordion: http://jsfiddle.net/darrenc/cngPS/

Currently the icon only po

19条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-22 19:16

    This is how I do it without any js.

    I used the icon glyphicon-triangle-right but it works with any other icon, what it does is that it applies a 90 degrees rotation to the icon when the panel is open or not. I'm using Bootstrap 3.3.5 for this one.

    CSS Code

    h4.panel-title a {
        display: block;
    
    }
    h4.panel-title a.collapsed .glyphicon-triangle-right {
            color: #ada9a9 !important;
            transform: rotate(0deg);
    }
    h4.panel-title a .glyphicon-triangle-right {
            color: #515e64 !important;
            transform: rotate(90deg);
    }
    

    This is the HTML structure taken from the Bootstrap example

    Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.

提交回复
热议问题