导航栏中的下拉菜单被隐藏
Drop Down Menu In Navigation Bar got Hidden
在现有的导航栏菜单中,我想在最后一个菜单项上添加和下拉菜单。但是,通过单击下拉菜单,菜单被隐藏了 html 正文,看起来像这样:
下拉菜单在Action menu上,点击时已经隐藏
这是我尝试做的事情:
html,
body {
background: #f7f7f8
}
.text-white {
color: #fff !important;
}
section.header {
padding: 90px 0;
}
.logo {
line-height: 60px;
/*position: fixed;*/
float: left;
margin: 0 46px;
color: #FFF;
font-weight: bold;
font-size: 20px;
letter-spacing: 2px;
}
nav {
/*display: flex;*/
background: #099cec;
height: 64px;
color: #FFF;
width: 100%;
line-height: 60px;
}
nav ul {
line-height: 60px;
list-style: none;
background: rgba(0, 0, 0, 0);
overflow: hidden;
color: #FFF;
padding: 0;
text-align: right;
margin: 0;
padding-right: 40px;
transition: 1s;
}
nav.black ul {
background: #000;
}
nav ul li {
display: inline-block;
padding: 0 40px;
;
}
nav ul li a,
nav ul li a:hover {
text-decoration: none;
color: #FFF;
font-size: 16px;
}
.menu-icon {
line-height: 60px;
width: 100%;
background: #000;
text-align: right;
box-sizing: border-box;
padding: 15px 24px;
cursor: pointer;
color: #fff;
display: none;
}
@media(max-width: 786px) {
.logo {
/*position: fixed;*/
color: #FFF;
top: 0;
margin-top: 16px;
}
nav ul {
max-height: 0px;
background: #000;
}
nav.black ul {
background: #000;
}
.showing {
max-height: 34em;
}
nav ul li {
box-sizing: border-box;
width: 100%;
padding: 24px;
text-align: center;
}
.menu-icon {
display: block;
}
}
.form-group {
position: relative;
}
.form-control {
background: #f7f7f8;
border: 0;
}
.has-feedback .form-control-feedback {
top: 10px;
}
.form-control-feedback {
position: absolute;
z-index: 2;
display: block;
width: 2.375rem;
height: 2.375rem;
line-height: 2.375rem;
text-align: center;
pointer-events: none;
color: #aaa;
top: 0;
left: auto;
right: 0;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<header>
<nav class="navbar">
<div class="menu-icon">
<i class="fa fa-bars fa-2x"></i>
</div>
<div class="logo">
<!-- <img src="mktlogo.jpg"> -->
<a href="/Morakot/Package" style="color: #FFF;">Morakot Package</a>
</div>
<div class="menu">
<ul>
<li>
<div class="form-group has-feedback">
<input type="text" class="form-control" placeholder="Find a package">
<span class="fa fa-search form-control-feedback" style=""></span>
</div>
</li>
<li><a href="/Morakot/Upload">Upload</a></li>
<li><a href="/Morakot/CopyToken">Copy Token</a></li>
<li><a href="#">Help</a></li>
<li>
<!-- Single button -->
<div class="btn-group dropdown">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Action <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</div>
</li>
</ul>
</div>
</nav>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
我的风格 sheet 缺少什么才能使我的下拉菜单正常工作?谢谢
如果你想让下拉菜单与主菜单重叠,你可以添加这个css
.menu-icon {
line-height: 60px;
width: 100%;
background: #000;
text-align: right;
box-sizing: border-box;
padding: 15px 24px;
cursor: pointer;
color: #fff;
display: none;
position: absolute;
left: 0px;
}
在现有的导航栏菜单中,我想在最后一个菜单项上添加和下拉菜单。但是,通过单击下拉菜单,菜单被隐藏了 html 正文,看起来像这样:
下拉菜单在Action menu上,点击时已经隐藏
这是我尝试做的事情:
html,
body {
background: #f7f7f8
}
.text-white {
color: #fff !important;
}
section.header {
padding: 90px 0;
}
.logo {
line-height: 60px;
/*position: fixed;*/
float: left;
margin: 0 46px;
color: #FFF;
font-weight: bold;
font-size: 20px;
letter-spacing: 2px;
}
nav {
/*display: flex;*/
background: #099cec;
height: 64px;
color: #FFF;
width: 100%;
line-height: 60px;
}
nav ul {
line-height: 60px;
list-style: none;
background: rgba(0, 0, 0, 0);
overflow: hidden;
color: #FFF;
padding: 0;
text-align: right;
margin: 0;
padding-right: 40px;
transition: 1s;
}
nav.black ul {
background: #000;
}
nav ul li {
display: inline-block;
padding: 0 40px;
;
}
nav ul li a,
nav ul li a:hover {
text-decoration: none;
color: #FFF;
font-size: 16px;
}
.menu-icon {
line-height: 60px;
width: 100%;
background: #000;
text-align: right;
box-sizing: border-box;
padding: 15px 24px;
cursor: pointer;
color: #fff;
display: none;
}
@media(max-width: 786px) {
.logo {
/*position: fixed;*/
color: #FFF;
top: 0;
margin-top: 16px;
}
nav ul {
max-height: 0px;
background: #000;
}
nav.black ul {
background: #000;
}
.showing {
max-height: 34em;
}
nav ul li {
box-sizing: border-box;
width: 100%;
padding: 24px;
text-align: center;
}
.menu-icon {
display: block;
}
}
.form-group {
position: relative;
}
.form-control {
background: #f7f7f8;
border: 0;
}
.has-feedback .form-control-feedback {
top: 10px;
}
.form-control-feedback {
position: absolute;
z-index: 2;
display: block;
width: 2.375rem;
height: 2.375rem;
line-height: 2.375rem;
text-align: center;
pointer-events: none;
color: #aaa;
top: 0;
left: auto;
right: 0;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<header>
<nav class="navbar">
<div class="menu-icon">
<i class="fa fa-bars fa-2x"></i>
</div>
<div class="logo">
<!-- <img src="mktlogo.jpg"> -->
<a href="/Morakot/Package" style="color: #FFF;">Morakot Package</a>
</div>
<div class="menu">
<ul>
<li>
<div class="form-group has-feedback">
<input type="text" class="form-control" placeholder="Find a package">
<span class="fa fa-search form-control-feedback" style=""></span>
</div>
</li>
<li><a href="/Morakot/Upload">Upload</a></li>
<li><a href="/Morakot/CopyToken">Copy Token</a></li>
<li><a href="#">Help</a></li>
<li>
<!-- Single button -->
<div class="btn-group dropdown">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Action <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</div>
</li>
</ul>
</div>
</nav>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
我的风格 sheet 缺少什么才能使我的下拉菜单正常工作?谢谢
如果你想让下拉菜单与主菜单重叠,你可以添加这个css
.menu-icon {
line-height: 60px;
width: 100%;
background: #000;
text-align: right;
box-sizing: border-box;
padding: 15px 24px;
cursor: pointer;
color: #fff;
display: none;
position: absolute;
left: 0px;
}