悬停时Bootstrap 4 Mega菜单

时间:2018-06-04 10:36:51

标签: bootstrap-4

我希望在bootstrap 4中构建一个悬停的大型菜单,就像下图中的那个一样 enter image description here

我已经在网上看了几个例子但是,它们与我的要求不符,因为我正在寻找悬停megamenu的全宽,正如你在图片中看到的那样。

我试过以下

<li class="nav-item dropdown">
  <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Category 1
    </a>
    <div class="dropdown-menu" aria-labelledby="navbarDropdown">
      <div class="container">
        <div class="row">
          <div class="col-md-4">
            <span class="text-uppercase text-white">Category 1</span>
            <ul class="nav flex-column">
              <li class="nav-item">
                <a class="nav-link active" href="#">Active</a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="#">Link item</a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="#">Link item</a>
              </li>
            </ul>
          </div>
          <!-- /.col-md-4  -->
          <div class="col-md-4">
            <ul class="nav flex-column">
              <li class="nav-item">
                <a class="nav-link active" href="#">Active</a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="#">Link item</a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="#">Link item</a>
              </li>
            </ul>
          </div>
          <!-- /.col-md-4  -->
          <div class="col-md-4">
            <a href="">
              <img src="https://dummyimage.com/200x100/ccc/000&text=image+link" alt="" class="img-fluid">
            </a>
            <p class="text-white">Short image call to action</p>
          </div>
          <!-- /.col-md-4  -->
        </div>
      </div>
      <!--  /.container  -->
    </div>
</li>

这不会给我全宽下拉和远离我需要的方式。

是否有人尝试过bootstrap 4并且可以帮助我生成与图像完全相同的菜单。

感谢任何帮助。

2 个答案:

答案 0 :(得分:0)

                                                                                           2类                                                     活性                                                     链接项                                                     链接项                                                                                                                                  活性                                                     链接项                                                     链接项                                                                                                                       

            </a>
            <p class="text-white">Short image call to action</p>

          </div>
          <!-- /.col-md-4  -->
        </div>
      </div>
      <!--  /.container  -->

答案 1 :(得分:-1)

<li class="nav-item dropdown">
  <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Category 1
    </a>
    <div class="dropdown-menu container-fluid" aria-labelledby="navbarDropdown">
        <div class="row">
          <div class="col-md-4">
            <span class="text-uppercase text-white">Category 1</span>
            <ul class="nav flex-column">
              <li class="nav-item">
                <a class="nav-link active" href="#">Active</a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="#">Link item</a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="#">Link item</a>
              </li>
            </ul>
          </div>
          <!-- /.col-md-4  -->
          <div class="col-md-4">
            <ul class="nav flex-column">
              <li class="nav-item">
                <a class="nav-link active" href="#">Active</a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="#">Link item</a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="#">Link item</a>
              </li>
            </ul>
          </div>
          <!-- /.col-md-4  -->
          <div class="col-md-4">
            <a href="">
              <img src="https://dummyimage.com/200x100/ccc/000&text=image+link" alt="" class="img-fluid">
            </a>
            <p class="text-white">Short image call to action</p>
          </div>
          <!-- /.col-md-4  -->
        </div>
    </div>
</li>

并将一些css用于悬停效果。

<style>
  .dropdown:hover>.dropdown-menu {
     display: block;
  }
</style>