Bootstrap collapse panel has visual problems using a collapse icon instated of heading

Issue

I am using a few collapsible bootstrap panels and instate of collapsing by clicking on the header as the example, I have an icon on the right side of the header that triggers the collapse. The collapse transition has a visual problem when doing that as you can see in the jsfiddle. It shrinks all panel-body content to position where the icon lies. See the JSFiddle for a simplified example.

https://jsfiddle.net/10bLdb5t/3/

Thanks!

HTML:

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<div class="panel-group">
  <div class="panel panel-default" id="panel1">      
    <div class="panel-heading">
      <a class="btn btn-collapse pull-right" data-toggle="collapse" href="#collapseOne">
        <i class="fa fa-caret-square-o-up"></i>
      </a>
      <h4 class="panel-title">
        Collapsible Group Item #1
      </h4>
    </div>      
    <div id="collapseOne" class="panel-collapse collapse in">
      <div class="panel-body">
        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.
      </div>
    </div>
  </div>
</div>

Solution

If you add this style rule

style="margin-top:-8px;"

to your a tag your problem is solved. Don’t know if it’s the best solution, but it works.

Answered By – doru

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published