13

我的bootstrap手風琴演奏氣質十足!我創建了三個顯示在列網格中的面板,但第二個和第三個摺疊菜單關閉了錯誤的菜單(例如,單擊/打開菜單2,然後單擊/打開菜單3將在打開菜單3之前關閉菜單2)。Bootstrap手風琴面板/摺疊

任何想法爲什麼?

代碼在這裏:

 <div class="row"> 
      <div class="col-sm-6 col-md-4"> 
       <div class="panel-group"> 
        <div class="panel panel-default"> 
         <a class="panel-default" data-toggle="collapse" data-parent="#accordion" href="#collapseOne"> 
         <div class="panel-heading"> 
          <h4 class="panel-title"> 
          My Story 
          </h4> 
         </div> 
         </a> 
         <div id="collapseOne" class="panel-collapse collapse"> 
          <div class="panel-body"> 
          Content 
          </div> 
         </div> 
        </div> 
       </div> 
      </div> 
      <div class="col-sm-6 col-md-4"> 
       <div class="panel-group" id="accordion"> 
        <div class="panel panel-default"> 
         <a class="panel-default" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo"> 
         <div class="panel-heading"> 
          <h4 class="panel-title"> 
          My Skills 
          </h4> 
         </div> 
         </a>        
         <div id="collapseTwo" class="panel-collapse collapse in"> 
          <div class="panel-body"> 
          Content 
          </div> 
         </div> 
        </div> 
       </div> 
      </div> 
      <div class="col-sm-6 col-md-4"> 
       <div class="panel-group" id="accordion"> 
        <div class="panel panel-default"> 
         <a class="panel-default" data-toggle="collapse" data-parent="#accordion" href="#collapseThree"> 
         <div class="panel-heading"> 
          <h4 class="panel-title"> 
          My Ambition 
          </h4> 
         </div> 
         </a>        
         <div id="collapseThree" class="panel-collapse collapse"> 
          <div class="panel-body"> 
          content 
          </div> 
         </div> 
        </div> 
       </div> 
      </div> 
     </div> 

回答

29

你需要編號手風琴即accordion1 accordion2 accordion3

<div class="row"> 
    <div class="col-sm-6 col-md-4"> 
     <div class="panel-group"> 
      <div class="panel panel-default"> 
       <a class="panel-default" data-toggle="collapse" data-parent="#accordion1" href="#collapseOne"> 
       <div class="panel-heading"> 
        <h4 class="panel-title"> 
        My Story 
        </h4> 
       </div> 
       </a> 
       <div id="collapseOne" class="panel-collapse collapse"> 
        <div class="panel-body"> 
        Content 
        </div> 
       </div> 
      </div> 
     </div> 
    </div> 
    <div class="col-sm-6 col-md-4"> 
     <div class="panel-group" id="accordion"> 
      <div class="panel panel-default"> 
       <a class="panel-default" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo"> 
       <div class="panel-heading"> 
        <h4 class="panel-title"> 
        My Skills 
        </h4> 
       </div> 
       </a>        
       <div id="collapseTwo" class="panel-collapse collapse in"> 
        <div class="panel-body"> 
        Content 
        </div> 
       </div> 
      </div> 
     </div> 
    </div> 
    <div class="col-sm-6 col-md-4"> 
     <div class="panel-group" id="accordion"> 
      <div class="panel panel-default"> 
       <a class="panel-default" data-toggle="collapse" data-parent="#accordion3" href="#collapseThree"> 
       <div class="panel-heading"> 
        <h4 class="panel-title"> 
        My Ambition 
        </h4> 
       </div> 
       </a>        
       <div id="collapseThree" class="panel-collapse collapse"> 
        <div class="panel-body"> 
        content 
        </div> 
       </div> 
      </div> 
     </div> 
    </div> 
</div> 
+5

嗯,哦Speghetti-OHS :)謝謝Zeeba,會投你了,但我仍然一個noob(正如你可能已經看到:) – tom1bomb

+3

lol,np。只是開心,我可以幫忙。 – Zeeba