Bootstrap 4导航棒在旋转木马顶部

时间:2018-03-20 13:30:34

标签: twitter-bootstrap carousel navbar

我的导航栏定位有点问题。我想把我的导航棒放在旋转木马的顶部。不是旋转木马,而是旋转木马,如字幕,但在所有滑块上。所以当滚动页面时,navbar和carousel将等于隐藏。

无法在文档中找到它。

试图放置整个<导航>进入旋转木马,但我认为这是不好的方式。

也许有一些类似“固定顶部”的类,我应该把它放在哪里?

“navbar-static-top”也没有用,或者我放错了地方?

这是navbar:

<nav class="navbar navbar-expand-md">
  <a class="navbar-brand" href="#">Navbar</a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon bg-danger"></span>
  </button>

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav mx-auto nav-fill w-100">
      <li class="nav-item active">
        <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Link1</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Link2</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Link3</a>
      </li>
    </ul>

  </div>
</nav>

这里有旋转木马:

<div id="carousel-fade" class="carousel carousel-fade" data-ride="carousel" data-interval="2000">
<ol class="carousel-indicators">
    <li data-target="#carousel-fade" data-slide-to="0" class="active"></li>
    <li data-target="#carousel-fade" data-slide-to="1"></li>
    <li data-target="#carousel-fade" data-slide-to="2"></li>
</ol>

<div class="carousel-inner embed-responsive embed-responsive-16by9" role="listbox">
  <div class="carousel-item embed-responsive-item active">
    <img src="slider1-2-1916x968.jpg" alt="First slide image" class="img-fluid">
    <div class="carousel-caption">
      <h3>First slide Heading</h3>
      <p>First slide Caption</p>
    </div>
  </div>

  <div class="carousel-item embed-responsive-item">
    <img src="slider2-2-1916x968.jpg" alt="Second slide image" class="img-fluid">
    <div class="carousel-caption">
      <h3>Second slide Heading</h3>
      <p>Second slide Caption</p>
    </div>
  </div>

  <div class="carousel-item embed-responsive-item">
    <img src="slider3-3-1916x968.jpg" alt="Third slide image" class="img-fluid">
    <div class="carousel-caption">
      <h3>Third slide Heading</h3>
      <p>Third slide Caption</p>
    </div>
  </div>
</div>

<a class="carousel-control-prev" href="#carousel-fade" role="button" data-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carousel-fade" role="button" data-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
</a>
</div>

1 个答案:

答案 0 :(得分:0)

我用非常简单的代码解决了这个问题。

只需添加

style =“ z-index:10;”

导航栏。

完成!