Bootstrap 4卡导航

时间:2017-11-07 00:49:26

标签: bootstrap-4

在Bootstrap 4 beta中,您可以向卡组件添加导航。 https://getbootstrap.com/docs/4.0/components/card/#navigation

但实际上没有工作示例如何在卡片内的不同标签之间切换。

例如,这对我不起作用。我也添加了javascript文件。

<div class="card">
    <div class="card-header">
        <ul class="nav nav-tabs card-header-tabs">
            <li class="nav-item">
                <a class="nav-link active" href="#foo">Foo</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#bar">Bar</a>
            </li>
        </ul>
    </div>
    <div class="card-body">
        <div class="tab-content">
            <div class="tab-pane" id="foo">FOO</div>
            <div class="tab-pane" id="bar">BAR</div>
        </div>
    </div>
</div>

1 个答案:

答案 0 :(得分:11)

尝试这样

 <div class="card ">
  <div class="card-header"> 
    <ul class="nav nav-tabs card-header-tabs pull-right"  id="myTab" role="tablist">
      <li class="nav-item">
       <a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Home</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" id="profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false">Profile</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" id="contact-tab" data-toggle="tab" href="#contact" role="tab" aria-controls="contact" aria-selected="false">Contact</a>
      </li>
    </ul>
  </div>
  <div class="card-body">
   <div class="tab-content" id="myTabContent">
             <div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">...</div>
  <div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
  <div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">...</div>
        </div>
  </div>
</div>

详细了解https://getbootstrap.com/docs/4.0/components/navs/