Bootstap:span class icon bar not working

此生再无相见时 提交于 2020-01-15 09:36:48

问题


I have used span class icon bar to display that three lines symbol after resizing the windows and other components should get displayed under that icon. But when I resize the window it only shows that icon and after clicking on it nothing happens This what I have done : what's gone wrong? Thank you in advance

 <body>
    <nav class="navbar navbar-inverse">
    <div class="container-fluid">

        <! Header -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#topNavBar">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="{% url 'ontheway:index' %}"> Way2go </a>
        </div>

        <! Items -->
        <div class="collapse navbar-collapse" id="#topNavBar">
            <ul class="nav navbar-nav">
                <li class="active">
                    <a href="{% url 'ontheway:index' %}">
                        <span aria-hidden="true"></span>&nbsp;&nbsp;Home
                    </a>
                </li>
                <li class="">
                    <a href="#">
                        <span aria-hidden="true"></span>&nbsp;&nbsp;Hotels
                    </a>
                </li>
                <li class="">
                    <a href="#">
                        <span aria-hidden="true"></span>&nbsp;&nbsp;Homestays
                    </a>
                </li>
            </ul>


            <form class="navbar-form navbar-left" role="search" method="get" action="#">
                <div class="form-group">
                    <input type="text" class="form-control" name="q" value=""placeholder="Search tourist places,hotels, homestays here">
                </div>
                <button type="submit" class="btn btn-default">&nbsp;Search</button>
            </form>


            <ul class="nav navbar-nav navbar-right">
                <li class="">
                    <a href="#">
                        <span class="glyphicon glyphicon-bell" aria-hidden="true"></span>&nbsp;Notifications
                    </a>
                <li class="">
                    <a href="#">
                        <span aria-hidden="true"></span>&nbsp;Log in
                    </a>
                </li>
                 <li class="">
                    <a href="#">
                        <span aria-hidden="true"></span>&nbsp;Sign up
                    </a>
                </li>

            </ul>
        </div>
    </div>
</nav>

回答1:


@pratik jaiswal, your issue stems from the value of the id attribute on your element with the collapse class.

  <!-- Header ---->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#topNavBar">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="{% url 'ontheway:index' %}"> Way2go </a>
        </div>

        <!-- Items ---->
        <div class="collapse navbar-collapse" id="#topNavBar"> <!--Take out the hash symbol-->
...

You have it with a leading #. If you take that out, your issue will be resolved.

You can see it in action in this codeply.



来源:https://stackoverflow.com/questions/46122964/bootstapspan-class-icon-bar-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!