Bootstrap折叠。 如何一次只扩展一个div

我怎样才能一次展示一个?

演示: http : //jsfiddle.net/tvvq59wv/

$('.collapser').click(function() { $(this).next().collapse('toggle'); }); 
  
asf t1
asf t1

提前致谢!

Bootstrap手风琴。 jQuery vs HTML-attributes

有两种方法可以解决您的问题。 您可以使用Javascript或分配HTML属性。 但首先我们简化了代码。

起点

  1. col-md-4 col-xs-4等于col-xs-4
  2. Bootstrap包含对齐类 。 您可以使用text-right类而不是style="text-align: right;"
  3. 请注意, .row类具有margin-right: -15px; margin-left: -15px;属性margin-right: -15px; margin-left: -15px; margin-right: -15px; margin-left: -15px; 。 你需要将 .row放在.container.container-fluid
  4. style="height: 0px;" 是不必要的。 collapse类将display属性设置为none
  5. id必须是唯一的。

让我们从这段代码开始:

https://jsfiddle.net/glebkema/a5q9mgho/

 @import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'); .text { margin-bottom: 20px; padding: 15px; } .mauve { background: #c9f } .mint { background: #9fc } .peach { background: #fc9 } .text.mauve { background: #edf } .text.mint { background: #dfe } .text.peach { background: #fed } 
 
left
center
right
text
left
center
right
text
left
center
right
text