bootstrap手风琴菜单开启和关闭问题

时间:2016-11-07 06:55:14

标签: javascript jquery css twitter-bootstrap

我已将自举手风琴菜单集成到我的网站Click here

当一个切换打开时我遇到的问题另一个切换不会关闭 我假设这是一个CSS问题,因为我无法想象我需要应用于我的html以获得这项工作的任何额外属性。

当切换菜单折叠时,css属性转到

.collapse .in { display: block }

                    <article class="panel-heading" role="tab" data-toggle="collapse" data-parent="#accordion" href="#NewsFive" aria-expanded="true" aria-controls="collapseFive">
                    <div class="panel-heading-date">
                        <span>06/10/2016</span>
                    </div>
                    <div class="panel-title panel-news">
                            <article>

                            </article>
                    </div>
                </article>
                <!-- PANEL HEADING ENDS HERE -->
                <div id="NewsFive" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingFive">

                    <div class="video-wrapper">
                                <source src="/assets/videos/the-future-of-retail.mp4" type="video/mp4">
                        </video>
                    </div>
                    <div class="playpause"></div>
                </div>
            </div><!-- PANEL ENDS HERE -->

只是想知道是否有人能发现可能导致此问题的任何事情

1 个答案:

答案 0 :(得分:0)

由于未匹配标题和标签内容的ID&,导致出现此问题。

请仔细检查手风琴以及 aria-controls =&#34; collapseOne&#34; aria-labelledby =&#34; headingOne&#34; 需要匹配。

&#13;
&#13;
#accordion .panel-heading { padding: 0;}
#accordion .panel-title > a {
	display: block;
	padding: 0.4em 0.6em;
    outline: none;
    font-weight:bold;
    text-decoration: none;
}
.panel-group {
    position: relative;
}
.panel-heading-date {
    position: absolute;
    width: 110px;
    background-color: #000;
    color: #fff;
    padding: 18px 0;
    text-align: center;
}
.accordio-panel-title {
    margin-left: 120px;
    padding: 20px 0;
    cursor: pointer;
}
.accordio-panel-title .panel-title {
    font-size: 14px;
    border: 0;
}
&#13;
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<br/>
<div class="container">
    <div class="row">
        <div class="col-md-12" id="main">
            <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
              <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingOne">                  
					<div class="panel-heading-date">
						10/13/2016
					</div>
					<div class="accordio-panel-title" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
							<h4 class="panel-title">Collapsible Group Item #1</h4>
					</div>
                </div>
                <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
                  <div class="panel-body">
                  <ul>
                      <li>The titles are block, so you don't have to click the text part to activate it</li>
                      <li>Indicators for expand / collapsing items</li>
                      <li>Removed title links' obnoxious :hover  underlinings, and outlines.</li>
                  </ul>
                </div>
                </div>
              </div>
              <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingTwo">
					<div class="panel-heading-date">
						10/13/2016
					</div>
					<div class="accordio-panel-title collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
						    <h4 class="panel-title">Collapsible Group Item #2</h4>
					</div>
                </div>
                <div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
                  <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">
                <div class="panel-heading" role="tab" id="headingThree">
					<div class="panel-heading-date">
						10/13/2016
					</div>
					<div class="accordio-panel-title collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
						    <h4 class="panel-title">Collapsible G roup Item #3</h4>
					</div>                
                </div>
                <div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
                  <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>
	 </div>	
<div>
&#13;
&#13;
&#13;