Bootstrap 3崩溃,有2个cols

时间:2014-11-18 16:11:14

标签: jquery twitter-bootstrap twitter-bootstrap-3

我必须cols(col-md-6)并想要在每个cols中崩溃,但当我点击一个面板时,其他人都不会关闭。 这是一个示例代码:

<div class="row">
    <div id="custom-collapse-0" class="panel-group">
        <div class="col-md-6">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4 class="panel-title">
                        <a href="#collapse1" data-parent="#custom-collapse-0" data-toggle="collapse" class="accordion-toggle">TITLE</a>
                    </h4>
                </div>
                <div class="panel-collapse collapse in" id="collapse1" style="">
                    <div class="panel-body">TEXT</div>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4 class="panel-title">
                        <a href="#collapse2" data-parent="#custom-collapse-0" data-toggle="collapse" class="accordion-toggle">TITLE</a>
                    </h4>
                </div>
                <div class="panel-collapse collapse in" id="collapse2" style="">
                    <div class="panel-body">TEXT</div>
                </div>
            </div>
        </div>
    </div>
</div>
是的,有人能帮帮我吗? 感谢

1 个答案:

答案 0 :(得分:3)

http://www.bootply.com/7M5lUWZK6e

这是一个有效的例子。我认为你的工作不起作用的原因是因为该列不是panel-default div的一部分。您需要清除面板上的填充。

<div class="row">   
<div class="panel-group" id="accordion">
  <div class="panel panel-default col-sm-6">
    <div class="panel-heading">
      <h4 class="panel-title">
        <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
          Collapsible Group Item #1
        </a>
      </h4>
    </div>
    <div id="collapseOne" class="panel-collapse collapse">
      <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 class="panel panel-default col-sm-6">
    <div class="panel-heading">
      <h4 class="panel-title">
        <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">
          Collapsible Group Item #2
        </a>
      </h4>
    </div>
    <div id="collapseTwo" class="panel-collapse collapse">
      <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>        
</div>