简体   繁体   中英

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.

Update : Even if i delete the navbar it can't work properly.

this is what I mean :

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 . Add to 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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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