设置引导程序下拉菜单的起点

时间:2018-10-24 09:18:46

标签: html css twitter-bootstrap drop-down-menu bootstrap-4

你好,我的bootstrap下拉菜单有一个问题,每个下拉菜单都必须从第一个nav选项开始,如下图所示。如果您需要更多信息,请告诉我,我会将其添加到这篇文章中。

我已经进行了一些研究,并且看到了一些有关大型菜单的示例,但是我无法在我的项目中使用它,所以我开始自己动手做。

enter image description here enter image description here

<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<style>
  .box {
    display: block;
    width: 100%;
    min-height: 250px;
    margin-bottom: 10px;
    padding: 5px;
  }
  
  .Tilebackground {
    background-color: #efefef !important;
    width: 200px !important;
    height: 145px !important;
    margin-right: 20px !important;
  }
  
  .Tileheader {
    font-family: 'Segoe UI Emoji';
    color: #414142;
    font-size: 18px;
    font-weight: 400;
    line-height: 12.926px;
    transform: scale(1.259, 1.259);
    text-align: center;
    margin-top: 20px;
  }
  
  .Tilefooter {
    font-family: 'Segoe UI';
    color: #414142;
    font-size: 12px;
    font-weight: 200;
    line-height: 18px;
    margin-top: 10px;
  }
  
  .dropdown-toggle::after {
    display: none;
  }
  
  .mega-menu {
    width: 863px !important;
    height: auto !important;
    background-color: grey;
  }
  
  .dropdown-item {
    color: white !important;
  }
  
  .btn {
    box-shadow: none !important;
  }
  
  .btn-secondary {
    border-color: initial !important;
  }
  
  .dropdown:hover>.dropdown-menu {
    display: block;
  }
  
  .relative {
    position: relative;
    top: 0;
  }
  
  .absolute {
    position: absolute;
  }
</style>
</head>

<body>
  <div class="container-fluid" style="background-color: #787878;">
    <div class="row">
      <nav class="navbar navbar-expand-lg navbar-dark" style="width: 100%; background-color: #787878; padding-left: 40px; padding-right: 40px;">
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent">
    				<span class="navbar-toggler-icon"></span>
				</button>
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
          <ul class="navbar-nav ml-auto">
            <li class="nav-item"><a class="nav-link" href="#">Over Connect Pro</a></li>
            <li class="nav-item"><a class="nav-link" href="#">Referenties</a></li>
            <li class="nav-item"><a class="nav-link" href="#">Vacatures</a></li>
            <li class="nav-item"><a class="nav-link" href="#">Contact</a></li>
          </ul>
        </div>
      </nav>
    </div>
  </div>

  <div class="container-fluid" style="background-color: #FFF; border-bottom: 1px solid #787878;">
    <div class="row">
      <nav class="navbar navbar-expand-lg navbar" style="width: 100%; padding: 20px; padding-left: 40px; padding-right: 40px;">
        <a class="navbar-brand" href="#" style="color: #000"><img src="images/toplogo.png" alt="Connect Pro"></a>
        <button class="navbar-toggler" style="color: #000" type="button" data-toggle="collapse" data-target="#navbarSupported">
    				<span class="navbar-toggler-icon" style="color: #000" ></span>
				</button>
        <div class="collapse navbar-collapse relative" id="navbarSupported">
          <ul class="navbar-nav ml-auto">
            <div class="dropdown">
              <button class="btn btn-secondary dropdown-toggle Tilebackground" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
						<p class="Tileheader">Onze aanpak</p>
						<p class="Tilefooter">PROACTIEVE ICT <br> ONDERSTEUNING <br> VOOR BEDRIJVEN</p>
					</button>
              <div class="dropdown-menu mega-menu w-100 absolute container" aria-labelledby="dropdownMenuButton">
                <div class="row w-100 d-flex">
                  <div class="col">
                    <a class="dropdown-item" href="#">Action</a>
                    <a class="dropdown-item" href="#">Another action</a>
                    <a class="dropdown-item" href="#">And an another action</a>
                    <a class="dropdown-item" href="#">one more action</a>
                    <a class="dropdown-item" href="#">Something else here</a>
                  </div>
                  <div class="col">
                    <a class="dropdown-item" href="#">Action</a>
                    <a class="dropdown-item" href="#">Another action</a>
                    <a class="dropdown-item" href="#">And an another action</a>
                    <a class="dropdown-item" href="#">one more action</a>
                    <a class="dropdown-item" href="#">Something else here</a>
                  </div>
                  <div class="col">
                    <a class="dropdown-item" href="#">Action</a>
                    <a class="dropdown-item" href="#">Another action</a>
                    <a class="dropdown-item" href="#">And an another action</a>
                    <a class="dropdown-item" href="#">one more action</a>
                    <a class="dropdown-item" href="#">Something else here</a>
                  </div>
                </div>
              </div>
            </div>
            <div class="dropdown">
              <button class="btn btn-secondary dropdown-toggle Tilebackground" type="button" id="dropdownMenuButton2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
						<p class="Tileheader">Oplossingen</p>
						<p class="Tilefooter">LOKALE INFRASTRUCTUUR,<br> CLOUD, VOIP, SECURITY, <br>TICKETING, MONITORING,...</p>
					</button>
              <div class="dropdown-menu mega-menu w-100 absolute container" aria-labelledby="dropdownMenuButton2">
                <div class="row w-100">
                  <div class="col">
                    <a class="dropdown-item" href="#">Action2</a>
                    <a class="dropdown-item" href="#">Another action2</a>
                    <a class="dropdown-item" href="#">Something else here2</a>
                  </div>
                  <div class="col">
                    <a class="dropdown-item" href="#">Action2</a>
                    <a class="dropdown-item" href="#">Another action2</a>
                    <a class="dropdown-item" href="#">Something else here2</a>
                  </div>
                  <div class="col">
                    <a class="dropdown-item" href="#">Action2</a>
                    <a class="dropdown-item" href="#">Another action2</a>
                    <a class="dropdown-item" href="#">Something else here2</a>
                  </div>
                </div>
              </div>
            </div>
            <div class="dropdown">
              <button class="btn btn-secondary dropdown-toggle Tilebackground" type="button" id="dropdownMenuButton3" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
						<p class="Tileheader">Producten</p>
						<p class="Tilefooter">FIREWALLS, PRINTERS, <br> NOTEBOOKS, SIP PHONES, <br>EN MEER</p>
					</button>
              <div class="dropdown-menu mega-menu w-100 absolute container" aria-labelledby="dropdownMenuButton3">
                <div class="row w-100">
                  <div class="col">
                    <a class="dropdown-item" href="#">Action3</a>
                    <a class="dropdown-item" href="#">Another action3</a>
                    <a class="dropdown-item" href="#">Something else here3</a>
                  </div>
                  <div class="col">
                    <a class="dropdown-item" href="#">Action3</a>
                    <a class="dropdown-item" href="#">Another action3</a>
                    <a class="dropdown-item" href="#">Something else here3</a>
                  </div>
                  <div class="col">
                    <a class="dropdown-item" href="#">Action3</a>
                    <a class="dropdown-item" href="#">Another action3</a>
                    <a class="dropdown-item" href="#">Something else here3</a>
                  </div>
                </div>
              </div>
            </div>
            <div class="dropdown">
              <button class="btn btn-secondary dropdown-toggle Tilebackground" type="button" id="dropdownMenuButton4" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
						<p class="Tileheader">Partners</p>
						<p class="Tilefooter">ONS NETWERK VAN <br> LOKALE IT PARTNERS <br>OVER HEEL BELGIË</p>
					</button>
              <div class="dropdown-menu dropdown-menu-right mega-menu container" aria-labelledby="dropdownMenuButton4">
                <div class="row">
                  <div class="col">
                    <a class="dropdown-item" href="#">Action4</a>
                    <a class="dropdown-item" href="#">Another action4</a>
                    <a class="dropdown-item" href="#">Something else here4</a>
                  </div>
                  <div class="col">
                    <a class="dropdown-item" href="#">Action4</a>
                    <a class="dropdown-item" href="#">Another action4</a>
                    <a class="dropdown-item" href="#">Something else here4</a>
                  </div>
                  <div class="col">
                    <a class="dropdown-item" href="#">Action4</a>
                    <a class="dropdown-item" href="#">Another action4</a>
                    <a class="dropdown-item" href="#">Something else here4</a>
                  </div>
                </div>
              </div>
            </div>
          </ul>
        </div>
      </nav>
    </div>
  </div>

1 个答案:

答案 0 :(得分:0)

一种快速的,有点棘手的修复程序,但这是我想到使用引导程序的唯一方法。

由于第一个框下拉列表可以正常工作,所以这很好。但是,对于其他三个盒子,我分别给了它们一个类(我使用了dd-2,dd-3和dd-4)。

我所做的只是将position: absolute; left:数字设置为减去按钮的宽度(220像素)

(添加)CSS:

.dd-2 //dropdown box 2 {
    left: -220px;
}

.dd-3 //dropdown box 3 {
    left: -440px;
}

.dd-4 //dropdown box 4 {
    left: -660px;
}

这是我的代码笔,显示了它的用法(很抱歉,我将代码拆分为代码笔):https://codepen.io/CodeBoyCode/pen/Pyyvgw

让我知道这是否是您想要的

谢谢