Bootstrap 4 - 悬停在主导航

时间:2017-10-10 18:12:11

标签: html css bootstrap-4

我是网页设计新手,我试图复制网页。我的问题是......

如何像我这样进行子导航? original subnav

目前我的一个是这样的。 my subnav

我正在使用最新的bootstrap版本。这是我的html / css代码。 顺便说一下,如果你们能详细解释我做错了什么,我会更加欣赏它。



body {
  font: 16px/1.5 'Roboto', 'Myriad Pro', sans-serif;
  padding: 0;
  margin: 0;
}

.navbar-light .navbar-nav .nav-link {
  color: #fff;
  margin: 0 30px;
}

#navbarSupportedContent {
  margin-left: 50px;
}

.btn {
  padding: .75rem 1.5rem;
  line-height: 1.25;
  margin-left: 30px;
}

.btn-outline-light:hover {
  background-color: transparent;
}

.btn-outline-light.focus, .btn-outline-light:focus {
  box-shadow: none;
}

.dropdown-menu{
	left: 0;
    min-width: 100% !important;
    position: absolute !important;
    right: 0;
	background: #bf1e2e;
	padding:13px 0px;
}


.dropdown-menu > li{
	display:inline-block;
}

ul.navbar-nav li:hover > div.dropdown-menu {
	display: block;
}

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <title>Intermark Mall | Welcome</title>
  <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400" rel="stylesheet">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
  <link rel="stylesheet" href="./css/style2.css">
</head>

<body>

  <nav class="navbar navbar-expand-lg navbar-light" style="background-color: #bf1e2e;">
    <div class="container">
      <a class="navbar-brand" href="#">
        <img src="http://i64.tinypic.com/213n9mc.png" width="275" height="90" alt="">
      </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"></span>
      </button>

      <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav mr-auto">
          <li class="nav-item dropdown">
            <a class="nav-link navbarDropdownMenuLink" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              ABOUT
            </a>
            <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
              <a class="dropdown-item" href="#">Mall Info</a>
              <a class="dropdown-item" href="#">Precincts</a>
              <a class="dropdown-item" href="#">Mall Location</a>
              <a class="dropdown-item" href="#">Getting There</a>
              <a class="dropdown-item" href="#">Car Park Info</a>
            </div>

          </li>
          <li class="nav-item dropdown">
            <a class="nav-link navbarDropdownMenuLink" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              STORES
            </a>
            <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
              <a class="dropdown-item" href="#">Directory</a>
              <a class="dropdown-item" href="#">Promotions</a>
              <a class="dropdown-item" href="#">Floor Plan</a>
            </div>
          </li>

          <li class="nav-item dropdown">
            <a class="nav-link navbarDropdownMenuLink" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              HAPPENINGS
            </a>
            <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
              <a class="dropdown-item" href="#">Events</a>
            </div>
          </li>

          <li class="nav-item dropdown">
            <a class="nav-link navbarDropdownMenuLink" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              CONTACT
            </a>
            <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
              <a class="dropdown-item" href="#">Talk to Us!</a>
            </div>
          </li>

          <a class="btn btn-outline-light" href="#" role="button">TOURIST PRIVILEGE</a>
        </ul>
      </div>
    </div>
  </nav>









  <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
</body>
</html>
&#13;
&#13;
&#13;

0 个答案:

没有答案