Bootstrap 3:嵌套选项卡

时间:2013-10-23 02:18:25

标签: javascript twitter-bootstrap twitter-bootstrap-3

我正在尝试在选项卡中放置一个选项卡,但每当我单击一个内部嵌套选项卡时,整个内部嵌套选项卡行就会消失。这是jsfiddle中的一个例子

http://jsfiddle.net/jNWMY/1/

点击“Acquisitions / Facebook”标签。您会注意到第二行标签消失了。

这是我的代码

<h1> Dashboard </h1>

<ul class="nav nav-tabs" id="dashboard_tabs">
    <li><a href="#acquisition_tab" data-toggle="tab"><b>Acquisition</b> <span style="color:red">(-30%)</span> <br> Total Installs</a></li>
    <li><a href="#engagement_tab" data-toggle="tab">Engagement</a></li>
    <li><a href="#retention_tab" data-toggle="tab">Retention</a></li>
    <li><a href="#revenue_tab" data-toggle="tab">Revenue</a></li>
</ul>

<div class="tab-content">

    <div id="acquisition_tab" class="tab-pane">
        <ul class="nav nav-tabs" id="dashboard_tabs">
            <li><a href="#all_acquisition_tab" data-toggle="tab"><b>All</b> <span style="color:red">(-30%)</span> <br> Total Installs</a></li>
            <li><a href="#facebook_acquisition_tab" data-toggle="tab"><b>Facebook</b> <span style="color:red">(-30%)</span> <br> Total Installs</a></a></li>
            <li><a href="#yahoo_acquisition_tab" data-toggle="tab"><b>Yahoo</b> <span style="color:red">(-30%)</span> <br> Total Installs</a></a></li>
        </ul>
    </div>

    <div id="engagement_tab" class="tab-pane">
        <p> Engagement tab </p>
    </div>

    <div id="retention_tab" class="tab-pane">
        <p> Retention tab </p>
    </div>

    <div id="revenue_tab" class="tab-pane">
        <p> Revenue tab </p>
    </div>

    <div id="all_acquisition_tab" class="tab-pane">
        <p> All acquisition </p>
    </div>  

    <div id="facebook_acquisition_tab" class="tab-pane">
        <p> All acquisition </p>
    </div>

    <div id="yahoo_acquisition_tab" class="tab-pane">
        <p> All acquisition </p>
    </div>  

</div>

1 个答案:

答案 0 :(得分:15)

您的内部标签应该包含在tab-content类的div中。

试试这个......

<h1> Dashboard </h1>

<ul class="nav nav-tabs" id="dashboard_tabs">
    <li><a href="#acquisition_tab" data-toggle="tab"><b>Acquisition</b> <span style="color:red">(-30%)</span> <br> Total Installs</a></li>
    <li><a href="#engagement_tab" data-toggle="tab">Engagement</a></li>
    <li><a href="#retention_tab" data-toggle="tab">Retention</a></li>
    <li><a href="#revenue_tab" data-toggle="tab">Revenue</a></li>
</ul>
<div class="tab-content">
    <div id="acquisition_tab" class="tab-pane">
        <ul class="nav nav-tabs" id="dashboard_tabs">
            <li><a href="#all_acquisition_tab" data-toggle="tab"><b>All</b><span style="color:red">(-30%)</span> <br> Total Installs</a></li>
            <li><a href="#facebook_acquisition_tab" data-toggle="tab"><b>Facebook</b><span style="color:red">(-30%)</span> <br> Total Installs</a></a></li>
            <li><a href="#yahoo_acquisition_tab" data-toggle="tab"><b>Yahoo</b><span style="color:red">(-30%)</span> <br> Total Installs</a></a></li>
        </ul>
    </div>
    <div id="engagement_tab" class="tab-pane">
        <p>Engagement tab</p>
    </div>
    <div id="retention_tab" class="tab-pane">
        <p>Retention tab</p>
    </div>
    <div id="revenue_tab" class="tab-pane">
        <p>Revenue tab</p>
    </div>
    <div class="tab-content">
        <div id="all_acquisition_tab" class="tab-pane">
            <p>All acquisition</p>
        </div>
        <div id="facebook_acquisition_tab" class="tab-pane">
            <p>All acquisition</p>
        </div>
        <div id="yahoo_acquisition_tab" class="tab-pane">
            <p>All acquisition</p>
        </div>
    </div>
</div>