gpt4 book ai didi

html - 无法在 bootstrap 3 的容器中放置菜单

转载 作者:行者123 更新时间:2023-11-28 01:17:45 26 4
gpt4 key购买 nike

以下是显示垂直菜单栏的代码,当我运行代码时 dropdown菜单来自 Bootstrap container .

谁能帮忙,我怎样才能把 div 放在容器里。

菜单应该只放在container里面,但在我的例子中是 <div class="container">不展开。

.mega-dropdown {
border: 2px solid #e0e0e0;
position: relative;
}

.mega-dropdown.active:before {
content: "";
position: absolute;
top: -2px;
right: -2px;
left: -2px;
height: 86px;
background: #ffffff;
border: 2px solid #77c04b;
-webkit-box-shadow: 0 0 21px 9px rgba(0, 0, 0, 0.14);
-moz-box-shadow: 0 0 21px 9px rgba(0, 0, 0, 0.14);
box-shadow: 0 0 21px 9px rgba(0, 0, 0, 0.14);
}

.mega-filtered-search .mega-dropdown.active:before {
border-color: #0083c9;
}

.mega-dropdown.active:after {
content: "";
position: absolute;
left: 0;
top: 2px;
width: 100%;
height: 80px;
background: #ffffff;
}

.mega-dropdown.active>i {
color: #686868;
}

.mega-dropdown.active .mega-content {
display: block;
}

.mega-dropdown.active .mega-content>.inner {
padding: 30px;
}

.mega-dropdown>button {
border: none;
background: none;
font-size: 14px;
line-height: 0;
top: 0;
height: 100%;
width: 100%;
position: absolute;
left: 0;
padding: 0 30px 0 15px;
text-align: left;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}

.mega-dropdown>i {
position: absolute;
right: 15px;
top: 50%;
font-size: 14px;
line-height: 0;
color: #b7b7b7;
}

.mega-content {
display: none;
width: 690px;
background: #fff;
border: 2px solid #77c04b;
position: absolute;
top: 100%;
left: -2px;
z-index: 21;
margin-top: 30px;
-webkit-box-shadow: 0 0 21px 9px rgba(0, 0, 0, 0.14);
-moz-box-shadow: 0 0 21px 9px rgba(0, 0, 0, 0.14);
box-shadow: 0 0 21px 9px rgba(0, 0, 0, 0.14);
}

.mega-filtered-search .mega-content {
border-color: #0083c9;
width: 304px;
}

.dropdown-wrap.active .mega-content {
display: block;
}

.dropdown-wrap .mega-content {
margin-top: 0;
border: 1px solid #f1f1f1;
-webkit-box-shadow: 0px 5px 0px 0px rgba(0, 0, 0, 0.14);
-moz-box-shadow: 0px 5px 0px 0px rgba(0, 0, 0, 0.14);
box-shadow: 0px 5px 0px 0px rgba(0, 0, 0, 0.14);
}

.dropdown-wrap .mega-content>.inner {
padding: 30px;
}

.mega-list>header {
font-size: 14px;
color: #151515;
text-transform: capitalize;
position: relative;
padding-left: 30px;
}

.mega-list>header i {
color: #77c04b;
font-size: 24px;
position: absolute;
left: 0;
top: 50%;
line-height: 0;
margin-top: -4px;
}

.mega-list ul {
margin: 15px -30px 0;
padding: 0 0 0 30px;
font-size: 13px;
}

.mega-list ul li {
display: block;
width: 25%;
float: left;
padding-right: 40px;
position: relative;
}

.mega-list ul li:after {
content: "\f105";
font-family: "FontAwesome";
position: absolute;
right: 33px;
top: 50%;
line-height: 0;
}

.mega-list ul li a {
display: block;
color: inherit;
}

.mega-filtered-search .mega-dropdown {
height: 50px;
position: absolute;
left: 0;
top: 0;
border: none;
background: #f4f4f4;
}

.category-list {
margin: 0;
padding: 0 0;
position: relative;
}

.category-list>li,
.category-list>li>ul li {
display: block
}

.category-list>li>a {
display: block;
padding: 12px 50px 12px 65px;
font-size: 14px;
position: relative
}

.category-list>li>a i {
position: absolute;
top: 50%;
left: 15px;
width: 50px;
text-align: center;
line-height: 0;
}

.category-list>li>a:after {
content: "\f105";
font-family: "FontAwesome";
position: absolute;
right: 30px;
top: 50%;
line-height: 0;
}

.category-list>li:hover>a {
background: #FED700;
color: #FFF
}

.category-list>li:hover>ul {
visibility: visible;
filter: alpha(opacity=100);
opacity: 1;
}

.category-list>li>ul {
visibility: hidden;
filter: alpha(opacity=0);
opacity: 0;
position: absolute;
left: 100%;
width: 100%;
top: -2px;
bottom: -2px;
overflow-y: auto;
background: #FED700;
padding: 0 0;
}

.category-list>li>ul li a {
display: block;
padding: 12px 30px;
font-size: 14px;
text-decoration: none;
color: #303E47
}

.category-list>li>ul li a:hover {
background: rgba(0, 0, 0, 0.05);
color: #303E47
}

.dropdown-wrap {
text-align: left;
position: relative;
}

.dropdown-wrap.active {
display: block;
}

.dropdown-wrap {
display: none;
border: 1px solid #b7b7b7;
background: #FFF;
width: 180px;
position: absolute;
right: 0;
top: 100%;
-webkit-box-shadow: 0 0 9px 1px rgba(0, 0, 0, 0.14);
-moz-box-shadow: 0 0 9px 1px rgba(0, 0, 0, 0.14);
box-shadow: 0 0 9px 1px rgba(0, 0, 0, 0.14);
}

.dropdown-wrap {
width: 370px;
}

.dropdown-wrap {
font-family: "FontAwesome";
content: "\f0d8";
color: #ffffff;
text-shadow: 0px -2px 0px #b7b7b7;
font-size: 22px;
position: absolute;
right: 15px;
line-height: 0;
top: -2px;
}

.mega-dropdown-wrap {
position: relative;
}

.mega-dropdown-wrap .mega-dropdown {
width: 100%;
border-width: 1px;
height: 42px;
max-width: 570px;
}

.mega-dropdown-wrap .mega-dropdown:before,
.mega-dropdown-wrap .mega-dropdown:after {
display: none !important;
}

.mega-dropdown-wrap .mega-dropdown .mega-content {
min-width: 200px;
width: 50%;
margin-top: 0;
border: 1px solid #e0e0e0;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
background: #f4f4f4;
left: -1px;
}

.mega-dropdown-wrap .mega-dropdown .mega-content .category-list>li>ul {
border-bottom: 1px solid #e0e0e0;
border-right: 1px solid #e0e0e0;
top: 0;
bottom: 0;
}

.container {
background: red;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div id="myGroup" class="container">
<div class="row rowd">
<h2 class="text-center">Select Category</h2>
<hr/>
<div class="panel">
<div class="row field-block">
<div class="col-xs-12 col-md-3">
<span class="required label"></span>
</div>
<div class="col-xs-12 col-md-9">
<div class="mega-dropdown-wrap">
<div class="mega-dropdown active">
<button>Select Category</button>
<i class="fa fa-navicon"></i>
<div class="mega-content">
<ul class="category-list">
<li><a href="#"><i class="fa fa-motorcycle"></i>Vehicles</a>
<ul>
<li><a href="#">Cars</a></li>
<li><a href="#">Bus, van, truck</a></li>
<li><a href="#">Industrial&nbsp;Vehicle</a></li>
<li><a href="#">Motorcycle</a></li>
<li><a href="#">Bicycle</a></li>
<li><a href="#">Spare Parts &amp; Accessories</a></li>
</ul>
</li>
<li><a href="#"><i class="fa fa-laptop"></i>Mobile&nbsp;&&nbsp;Computer</a>
<ul>
<li><a href="#">Mobile</a></li>
<li><a href="#">Computer&nbsp;&&nbsp;Laptop</a></li>
<li><a href="#">tablets</a></li>
<li><a href="#">iPads</a></li>
<li><a href="#">Accessories</a></li>
</ul>
</li>
<li><a href="#"><i class="fa fa-cc-diners-club"></i>Home&nbsp;Appliances</a>
<ul>
<li><a href="#">TV-Audio-Video</a></li>
<li><a href="#">Ac</a></li>
<li><a href="#">Washing&nbsp;Machine</a></li>
<li><a href="#">Fridge</a></li>
<li><a href="#">Camera&nbsp;&&nbsp;Lense</a></li>
<li><a href="#">Kitchen&nbsp;Accessories</a></li>
<li><a href="#">Game-Entertainment</a></li>
</ul>
</li>
<li><a href="#"><i class="fa fa-building"></i>Real&nbsp;Estate</a>
<ul>
<li><a href="#">For Sale</a></li>
<li><a href="#">For Rent</a></li>
</ul>
</li>
<li><a href="#"><i class="fa fa-female"></i>Fashion</a>
<ul>
<li><a href="#">Men</a></li>
<li><a href="#">Women</a></li>
<li><a href="#">Kids</a></li>
</ul>
</li>
<li><a href="#"><i class="fa fa-co"></i>Furniture</a>
<ul>
<li><a href="#">Sofa&nbsp;&&nbsp;Dining</a></li>
<li><a href="#">Bed&nbsp;&&nbsp;Wardrobes</a></li>
<li><a href="#">Home&nbsp;Decor&nbsp;and&nbsp;garden</a></li>
<li><a href="#">Kids&nbsp;Furniture</a></li>
<li><a href="#">other&nbsp;furniture</a></li>
</ul>
</li>
<li><a href="#"><i class="adicon-bell"></i>Jobs</a>
<ul>
<li><a href="#">Data Entry & Back Office</a></li>
<li><a href="#">BPO and Telecaller</a></li>
<li><a href="#">Sales and Marketing</a></li>
<li><a href="#">Operator and Technician</a></li>
<li><a href="#">Cook</a></li>
<li><a href="#">IT Engineer and Developer</a></li>
<li><a href="#">Designer</a></li>
<li><a href="#">Reception and Front Office</a></li>
<li><a href="#">Accountant</a></li>
<li><a href="#">Teacher</a></li>
<li><a href="#">Other Jobs</a></li>
</ul>
</li>
<li><a href="#"><i class="adicon-hat"></i>Services</a>
<ul>
<li><a href="#">Driver and Taxi</a></li>
<li><a href="#">Electronic Repair</a></li>
<li><a href="#">Computer Center</a></li>
<li><a href="#">Health and Beauty</a></li>
<li><a href="#">Gym and Fitness</a></li>
<li><a href="#">Sports and Equipment</a></li>
<li><a href="#">Other Services</a></li>
</ul>
</li>
<li><a href="#"><i class="adicon-dog"></i>Pets</a>
<ul>
<li><a href="#">Dogs</a></li>
<li><a href="#">Cats</a></li>
<li><a href="#">Food & Accessories</a></li>
<li><a href="#">Other Pets</a></li>
</ul>
</li>
<li><a href="#"><i class="adicon-heal"></i>Education</a>
<ul>
<li><a href="#">Books</a></li>
<li><a href="#">Online&nbsp;Tutorials</a></li>
<li><a href="#">Tution</a></li>
</ul>
</li>
<li><a href="#"><i class="adicon-smile"></i>Matrimony</a>
<ul>
<li><a href="#">I&nbsp;Aa&nbsp;Male</a></li>
<li><a href="#">i&nbsp;am&nbsp;female</a></li>
</ul>
</li>
<li><a href="#"><i class="adicon-hearts"></i>Note&nbsp;&&nbsp;Coin</a>
<ul>
<li><a href="#">Note</a></li>
<li><a href="#">Coins</a></li>
</ul>
</li>
</ul>
<div class="bor"></div><br>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="clearfix"></div><br>
</div>
</div>

最佳答案

因此,如果我做对了,您希望首先显示顶级菜单项,然后在单击其中任何一个时,您希望在所单击的元素下显示所单击元素下的子菜单。

如果是这种情况,您可以使用“data-toggle”和“data-taregt 属性,如下所示”来实现此效果。

<nav>
<ul class="nav">
<li><a href="#" id="btn1" data-toggle="collapse" data-target="#submenu" aria-expanded="false">Toggle Me</a>
<ul class="nav collapse" id="submenu" role="menu" aria-labelledby="btn1">
<li><a href="#">Submenu1</a></li>
<li><a href="#">Submenu2</a></li>
<li><a href="#">Submenu3</a></li>
</ul>
</li>
</ul>
</nav>

这只是示例,使用此逻辑进一步构建其他菜单项,它们将在单击的元素正下方打开。

关于html - 无法在 bootstrap 3 的容器中放置菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51715426/

26 4 0
文章推荐: javascript - Regex.compile 在 Ruby 中做什么?
文章推荐: C++ primer 加 Chapter14 无类型堆栈
文章推荐: css - 在所有页面上使用单个导航栏,而不复制它?
文章推荐: javascript - Angular.js 中
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com