gpt4 book ai didi

html - 设置 Bootstrap 下拉菜单的起点

转载 作者:行者123 更新时间:2023-11-28 00:55:24 25 4
gpt4 key购买 nike

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

我已经做了一些研究,也看过一些关于大型菜单的例子,但我无法在我的元素中使用它,所以我开始自己动手。

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>

最佳答案

一种快速、略显笨拙的修复方法,但这是我能想到的使用 bootstrap 的唯一方法。

由于第一个框下拉列表工作正常,所以这个很好。然而,对于其他 3 个盒子,我给了他们每个盒子(我使用了 dd-2、dd-3 和 dd-4)。

我所做的只是将 position: absolute; left: 图形设置为减去按钮的宽度 (220px)

(添加)CSS:

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

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

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

这是我的 codepen,展示了它是如何使用的(抱歉,我将你的代码拆分为我的 codepen):https://codepen.io/CodeBoyCode/pen/Pyyvgw

让我知道这是否是您要找的东西

谢谢

关于html - 设置 Bootstrap 下拉菜单的起点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52965303/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com