简体   繁体   English

Bootstrap 3:折叠手风琴无法正常工作

[英]Bootstrap 3 : Collapse Accordion Not Working

I create a web page with jquery and bootstrap, but my accordion not working if there a navbar, if i delete the navbar it can work properly. 我用jquery和bootstrap创建了一个网页,但是如果有导航栏,则我的手风琴无法正常工作,如果删除导航栏,它可以正常工作。

Update : Even if i delete the navbar it can't work properly. 更新:即使我删除了导航栏,它也无法正常工作。

this is what I mean : 这就是我的意思:

http://jsfiddle.net/4UN4M/9/ http://jsfiddle.net/4UN4M/9/

<body>
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
    <div class="container">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span class="sr-only">Toggle navigation</span>  <span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>

            </button> <a class="navbar-brand" href="#">IBSApps</a>

        </div>
        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li><a href="#" id="dashlink"><span class="glyphicon glyphicon-home"></span>Dashboard</a>

                </li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li class="dropdown" id="profiling"><a href="#" class="dropdown-toggle" data-toggle="dropdown" id="proflink"><span
                class="glyphicon glyphicon-user"></span> Suryo Sapoetro <b class="caret"></b></a>

                    <ul class="dropdown-menu">
                        <li><a href="#"><span class="glyphicon glyphicon-user"></span>Profile <span class="small text-info">beta</span></a>

                        </li>
                        <li><a href="#"><span class="glyphicon glyphicon-cog"></span>Settings <span class="small text-info">beta</span></a>

                        </li>
                        <li class="divider"></li>
                        <li><a href="#"><span class="glyphicon glyphicon-off"></span>Logout</a>

                        </li>
                    </ul>
                </li>
            </ul>
        </div>
        <!-- /.navbar-collapse -->
    </div>
</div>
<div class="container"></div>
<div class="container">
    <div id="container" class="row">
        <div class="col-lg-8">
            <div class="panel-group" id="accordion">
                <div class="panel panel-default">
                    <div class="panel-heading">
                         <h4 class="panel-title">
    <a data-toggle="collapse" data-parent="#accordion" href="#collapseone">
      Collapsible Group Item #1
    </a>
  </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 class="panel panel-default">
                    <div class="panel-heading">
                         <h4 class="panel-title">
    <a 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 class="panel panel-default">
                    <div class="panel-heading">
                         <h4 class="panel-title">
    <a data-toggle="collapse" data-parent="#accordion" href="#collapsethree">
      Collapsible Group Item #3
    </a>
  </h4>

                    </div>
                    <div id="collapseThree" 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>
        <div class="col-lg-4">
            <div class="row"></div>
        </div>
    </div>
</div>
<!-- /.container -->
</body>

sorry for my english. 对不起我的英语不好。 thanks in advance. 提前致谢。

That's because the navigation has a position:fixed . 这是因为导航具有position:fixed Add to div #accordion{ margin-top:60px;} . 添加到div #accordion{ margin-top:60px;} This is the fix for the positioning. 这是定位的解决方法。 Can you check in the console what jQuery error do you have and post it? 您可以在控制台中检查您遇到什么jQuery错误并将其发布吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM