本文介绍了Bootsrap页面冲突中的两个响应式导航栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Bootstrap响应式框架我必须在页面中使用两个导航栏.它们工作正常,但在切换模式下,单击图标会同时列出两个"nav-collapce"项!

我尝试将折叠类的名称重命名为第二个类,但是它不起作用.能否让我知道如何两次运行两次"nav-collapse崩溃"而没有任何冲突?

<div class="navbar">
<div class="navbar-inner">
    <div class="container">
        <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        </a>
        <a class="brand" href="#">Candete</a>
        <div class="nav-collapse collapse">
            <!-- .nav, .navbar-search, .navbar-form, etc -->
            <ul class="nav">
                <li class="active"><a href="#">Home</a></li>
                <li><a href="#">Products</a></li>
                <li><a href="#">Contact Us</a></li>
                <li><a href="#">About Us</a></li>
                <li><a href="#">All Products</a></li>
            </ul>
        </div>
    </div>
</div>
</div>

<div class="navbar">
<div class="navbar-inner">
    <div class="container">
        <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        </a>
        <a class="brand" href="#">Product Category</a>
        <div class="nav-collapse collapse">
            <!-- .nav, .navbar-search, .navbar-form, etc -->
            <ul class="nav">
                <li><a href="#">Gold</a></li>
                <li><a href="#">Copper</a></li>
                <li><a href="#">Zinc</a></li>
                <li><a href="#">Metals</a></li>
                <li><a href="#">Other</a></li>
            </ul>
        </div>
    </div>
</div>
解决方案

在Twitter Bootstrap中,.nav-collapse是重要的类,因此请勿更改.什么是最佳解决方案?

在行<div class="nav-collapse collapse">上添加一些新类,我们将其称为.menu1.因此,新代码将为<div class="nav-collapse collapse menu1">.然后data-target=".nav-collapse"更改为data-target=".menu1".

您可以对第二个菜单和某些新的.menu2类执行相同的操作,或将其保持原样(这将起作用,因为两个菜单具有不同的data-target).

这是工作示例 http://jsfiddle.net/xmLDd/

Using Bootstrap Responsive Framework I have to use two Nav bars in my page. they work fine but in a toggle mode clicking on icon lists both "nav-collapce" items!

I tried to rename the collapse class name for second class but it didn't work. Can you please let me know how I can run both "nav-collapse collapse two times without any conflict?

<div class="navbar">
<div class="navbar-inner">
    <div class="container">
        <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        </a>
        <a class="brand" href="#">Candete</a>
        <div class="nav-collapse collapse">
            <!-- .nav, .navbar-search, .navbar-form, etc -->
            <ul class="nav">
                <li class="active"><a href="#">Home</a></li>
                <li><a href="#">Products</a></li>
                <li><a href="#">Contact Us</a></li>
                <li><a href="#">About Us</a></li>
                <li><a href="#">All Products</a></li>
            </ul>
        </div>
    </div>
</div>
</div>

<div class="navbar">
<div class="navbar-inner">
    <div class="container">
        <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        </a>
        <a class="brand" href="#">Product Category</a>
        <div class="nav-collapse collapse">
            <!-- .nav, .navbar-search, .navbar-form, etc -->
            <ul class="nav">
                <li><a href="#">Gold</a></li>
                <li><a href="#">Copper</a></li>
                <li><a href="#">Zinc</a></li>
                <li><a href="#">Metals</a></li>
                <li><a href="#">Other</a></li>
            </ul>
        </div>
    </div>
</div>
解决方案

In Twitter Bootstrap, .nav-collapse is important class, so don't change it. What is best solution?

On line <div class="nav-collapse collapse"> add some new class, let's call it .menu1. So new code will be <div class="nav-collapse collapse menu1">. And then data-target=".nav-collapse" change to data-target=".menu1".

You can do the same thing with second menu and with some new .menu2 class, or leave it as it is (it will work, because both menus have different data-target).

And here is working demo http://jsfiddle.net/xmLDd/

这篇关于Bootsrap页面冲突中的两个响应式导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 23:33