php - 使用 Twitter Bootstrap 的药丸导航

标签 php twitter-bootstrap nav

我正在尝试使用 Twitter Bootstrap 的药丸导航,但它无法正常工作。

我确实已将“事件”类添加到我的选项卡内容中。然而,这就是发生的一切——我实际上没有看到内容有任何变化。所有内容只是按顺序显示,而不是包装到选项卡 Pane 中。

这是 PHP。请注意,我只是在 header 中包含 bootstrap.js。

<section id="about" class="section tabbable">
    <!-- Section Title -->
    <?php echo '<h2>' . $section->post_title . '</h2>'; ?>

    <!-- Subsection Title Navigation -->
    <?php if (!empty($section_children)){ //if other sections exist, add them
            echo '<ul class="nav nav-pills" id="an">';
            echo '<li class="active">' . '<a data-toggle="pill" href="#' . $section->post_name . '-content">' . $section->post_title . '</a></li>';

            foreach($section_children as $subsection){
                echo '<li>' . '<a data-toggle="pill" href="#' . $subsection->post_name . '">' . $subsection->post_title . '</a></li>';
            }
            echo '</ul><!--"/.nav-pills"-->';   
          }?>

    <div class="contentArea tab-content">
  <?php echo '<article class="contents tab-pane active" id="' . $section->post_name . '-content">' . apply_filters('the_content', $section->post_content) . '</article><!-- /.contents -->';?>

  <?php if (!empty($section_children)){ //if other sections exist, add them
            foreach($section_children as $subsection){
                echo '<div class="contents tab-pane" id="' . $subsection->post_name . '">';
                echo '<h2>' . $subsection->post_title . '</h2>';
                echo '<article>' . apply_filters('the_content', $subsection->post_content) . '</article></div><!-- /.contents -->';
            }   
        }?>
    </div><!-- /.contentArea -->
</section><!-- /.section -->

知道为什么我的内容始终可见并且不包含在选项卡 Pane 中吗?

编辑:查看生成的 HTML 可能会更容易:

<section id="about" class="section tabbable" style="height: 743px; ">
    <!-- Section Title -->
    <h2>About</h2>      
    <!-- Subsection Title Navigation -->
    <ul class="nav nav-pills" id="an">
        <li class=""><a data-toggle="pill" href="#about-content">About</a></li>
        <li class="active"><a data-toggle="pill" href="#execs">Your Executives</a></li>
        <li class=""><a data-toggle="pill" href="#governing-documents">Governing Documents</a></li>
    </ul><!--"/.nav-pills"-->   
    <div class="contentArea tab-content">
        <div class="contents tab-pane" id="about-content" style="width: 1019px; padding-left: 0px; ">
            <!-- …contents… -->
        </div><!-- /.contents -->     
        <div class="contents tab-pane active" id="execs" style="width: 1019px; padding-left: 0px; ">
            <!-- …contents… -->       
        </div><!-- /.contents -->
        <div class="contents tab-pane" id="governing-documents" style="width: 1019px; padding-left: 0px; ">
            <!-- …contents… -->
        </div><!-- /.contents -->       
    </div><!-- /.contentArea -->
</section>

最佳答案

如果您没有正确加载 bootstrap.css 文件,您将会遇到此行为。或者 LESS 的编译可能不包含 navs.less 文件。

否则,你的代码对我有用:

JSFiddle

关于php - 使用 Twitter Bootstrap 的药丸导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11953196/

相关文章:

html - 我将如何使这个导航栏下拉?

php - PHP邮件功能无法完成电子邮件的发送

php - android中的LoginActivity没有得到php json

php - Paypal 链式支付允许多少个二级收款人?

css - 设置内联表单的表单宽度 - 响应式 Bootstrap

html - Bootstrap v2 Accordion 与 bootstrap v3 - 哪个类(class)发生了变化?

php - pdo 准备好的语句不更新

javascript - 将工具提示添加到进度条 Bootstrap

html - Bootstrap 导航折叠到网站主体

html - 如何在垂直导航栏上的这些按钮之间放置空格?