HTML导航标签不起作用

时间:2017-02-02 05:34:50

标签: html twitter-bootstrap navbar nav

嗨,我在引导程序上有复杂性。我的代码没有用,有什么不对吗?有什么想法解决这个问题吗? - 谢谢

<nav id='nav-reservation'>
    <div class="container">
        <ul class="nav nav-tabs">
            <a href='resource-index.php?page=room' class='nav-reservation-item <?php if($_REQUEST[' page '] == "room"){ echo "active"; } ?>'>Room</a>
            <a href='resource-index.php?page=equipment' class='nav-reservation-item <?php if($_REQUEST[' page '] == "equipment"){ echo "active"; } ?>'>Equipment </a>
            </ul>
    </div>

    <div class="tab-content">
        <div id="room" class="tab-pane fade in active"></div>
        <div id="equipment" class="tab-pane fade in active"></div>
     </div>   
</nav>

2 个答案:

答案 0 :(得分:2)

您忘了在ul标签中添加li标签。

<nav id='nav-reservation'>
<div class="container">
    <ul class="nav nav-tabs">
       <li> <a href='resource-index.php?page=room' class='nav-reservation-item <?php if($_REQUEST[' page '] == "room"){ echo "active"; } ?>'>Room</a></li>
    <li>    <a href='resource-index.php?page=equipment' class='nav-reservation-item <?php if($_REQUEST[' page '] == "equipment"){ echo "active"; } ?>'>Equipment </a></li>
        </ul>
</div>

<div class="tab-content">
    <div id="room" class="tab-pane fade in active"></div>
    <div id="equipment" class="tab-pane fade in active"></div>
 </div>   

答案 1 :(得分:0)

首先,您的选项卡内容窗格都包含in active个类,而应该拥有这些类的唯一选项是活动的打开窗格。将这两个类与in active类同时显示两个选项卡。

接下来,选项卡由导航标签的href中的主题标签激活。你没有标签。它们应与要打开的选项卡窗格相对应。因此,如果要在导航选项卡的href中打开标识为#room的选项卡,则应指定此选项。你也应该将data-toggle="tab"放在href中,如下所示:

<a data-toggle="tab" href="#room">Room</a>

这将打开标识为#room

的标签

因此,如果没有自定义的php,您的标记应该类似于以下内容:

    <ul class="nav nav-tabs">
      <li class="active"><a  data-toggle="tab" href="#room">Room</a></li>
      <li><a  data-toggle="tab" href="#equipment">Equipment</a></li>
    </ul>

    <div class="tab-content">
      <div id="room" class="tab-pane fade in active">
        First Tab
      </div>
      <div id="equipment" class="tab-pane fade">
        Second Tab
      </div>
    </div>