在Bootstrap 4.1.3中构建导航栏时,右侧的下拉列表使用.dropdown-menu-right类,以防止其在浏览器右侧被剪切。在IE10 +中,当下拉列表扩大时,它将在右侧进一步推动利润(请参见此处的示例)(由于与客户的NDA关系,Navbar品牌已被删除)
.topnav{
padding: 10px 20px 0px 20px;
}
.navbar {
border: 1px solid transparent;
margin-bottom: 0;
max-height: 80px !important;
position: relative;
}
.navbar-nav > li > a {
font-weight: 600;
}
.navbar-nav {
flex-direction: row;
z-index: 3;
}
.navbar-nav > li > a {
line-height: 57px;
font-size: 17px;
height: 110px;
max-height: 150px;
margin-top: 20px;
}
.search-nav {
z-index: 1;
background: inherit;
margin-top: -45px;
padding-right: 20px;
margin-bottom: 0;
background-color:#77C044;
float: right;
}
/*.navbar-nav.topnav-badges > li > a {
line-height: 27px;
height: 37px;
}*/
.navbar-nav.bottomnav {
flex-direction: row;
text-align: center;
}
.navbar-nav.bottomnav > li > a {
line-height: 37px;
height: 60px;
}
.navbar-default {
background-color: #77C044;
border-color: #77C044;
margin-bottom: 30px;
}
.dropdown:hover > dropdown-menu {
display: flex;
margin: -0.125rem 0 0;
}
.dropdown-submenu {
position: relative;
}
.dropdown-menu-right {
right: 0;
left: auto;
}
@media screen and (min-width:992px) and (max-width:1215px) {
.navbar-brand {
height: 40px;
}
.navbar-nav > li > a {
font-size: 16px;
}
}
@media screen and (max-width:1215px) {
.container {
margin-top: 80px;
}
}
@media screen and (max-width:991px) {
.container {
margin-top: 200px;
margin-bottom: 100px;
}
.search-nav {
margin-bottom: 10px;
}
}
.dropup > .dropdown-menu {
margin: 0;
}
.dropdown {
margin: 0;
}
.submenu > .dropdown-menu {
margin: 0;
}
.dropdown-submenu a::after {
transform: rotate(-90deg);
position: absolute;
right: 6px;
top: .8em;
}
.dropdown-submenu .dropdown-menu {
top: 0;
left: 100%;
margin-left: .1rem;
margin-right: .1rem;
}
.navbar-default .navbar-nav > li > a {
color: #ffffff;
}
.navbar-default .navbar-nav > .active > a, .navbar-default .navbar-nav > .active > a:hover, .navbar-default .navbar-nav > .active > a:focus {
color: #254609;
background-color: transparent;
border-bottom: 5px solid #254609;
}
.navbar-default .navbar-nav > li > a:hover, .navbar-default .navbar-nav > li > a:focus {
color: #254609;
background-color: transparent;
border-bottom: 5px solid #254609;
}
.navbar-default .topnav-badges > li > a:hover, .topnav-badges > li > a:focus {
color: #254609;
background-color: transparent;
border-bottom: 0 !important;
}
.navbar-power-grid {
background-color: #ffffff;
border-color: #fff;
}
.navbar-brand-left, .navbar-environment-label {
display: table-cell;
vertical-align: middle;
}
.navbar-brand {
float: left;
height: 60px;
font-size: 16px;
line-height: 30px;
}
.navbar-environment-label {
font-size: 12px;
vertical-align: bottom;
}
.user-name, .user-name a {
color: #fff;
}
.user-name span {
font-weight: 700;
}
.user-name {
line-height: 28px;
padding-bottom: 5px;
padding-right: 15px;
padding-top: 15px;
}
.navbar-inverse {
background: #2e557c;
}
.navbar-inverse .navbar-nav > .active > a, .navbar-inverse .navbar-nav > .active > a:hover, .navbar-inverse .navbar-nav > .active > a:focus {
background-color: #77C044;
color: #fff;
}
.navbar-inverse .navbar-nav > li > a {
color: #fff;
}
.navbar-inverse .navbar-nav > .open > a, .navbar-inverse .navbar-nav > .open > a:hover, .navbar-inverse .navbar-nav > .open > a:focus {
background-color: #ffffff;
color: #423e37;
}
.open .dropdown-menu {
display: block;
position: absolute;
z-index: 2;
}
.dropdown-menu {
background-clip: padding-box;
background-color: #ffffff;
border: 1px solid #77C044;
border-radius: 0;
box-shadow: 0;
display: none;
float: left;
font-size: 14px;
list-style: outside none none;
margin: 0;
min-width: 160px;
padding: 0;
text-align: left;
top: 100%;
max-width: 100%;
z-index: 3;
position: relative;
right: 0;
left: auto;
}
.dropdown-menu > li > a {
clear: both;
color: #423e37;
display: block;
font-weight: normal;
line-height: normal !important;
padding: 7px 20px;
margin: 0;
white-space: nowrap;
border-bottom: 1px solid #AEAEAE;
overflow: hidden;
}
.navbar-default .navbar-nav > .open > a, .navbar-default .navbar-nav > .open > a:hover, .navbar-default .navbar-nav > .open > a:focus {
color: #555;
background-color: transparent;
}
.dropdown-menu > li > a:hover, .dropdown-menu > li > a:focus {
color: #423e37;
text-decoration: none;
background-color: rgba(255,255,255,0.1);
font-weight: 700;
overflow: hidden;
}
.dropdown-menu > .active > a, .dropdown-menu > .active > a:hover, .dropdown-menu > .active > a:focus {
color: #423e37;
text-decoration: none;
background-color: #ffffff;
outline: 0;
}
.dropdown-menu-right {
overflow: hidden;
}
.dropdown-header {
display: block;
padding: 3px 20px;
font-size: 16px;
line-height: 1.42857143;
color: #fff;
white-space: nowrap;
}
<nav class="nav navbar-nav topnav navbar-expand-lg navbar-default align-item-center d-none d-md-flex" style="margin-bottom: 0;padding-right:20px;padding-bottom:0;">
<div class="d-flex">
<ul class="navbar-nav flex-row">
<li class="nav-item left-nav"> <a href="#" class="nav-link">Files </a> </li>
<li class="nav-item left-nav"> <a href="#" class="nav-link">Rolodex</a> </li>
<li class="nav-item left-nav"> <a href="#" class="nav-link">Escrow Accounting</a> </li>
<li class="nav-item left-nav"> <a href="#" class="nav-link">Back Office</a> </li>
</ul>
</div>
<div class ="navbar-nav ml-sm-auto">
<ul class="navbar-nav topnav-badges flex-row">
<li class="nav-item"> <a href="" class="nav-link"><i class="fa fa-calendar" aria-hidden="true"></i> <span class="badge">42</span><span class="d-md-none">Calendar</span></a> </li>
<li class="nav-item"> <a href="" class="nav-link"><i class="fa fa-envelope" aria-hidden="true"></i> <span class="badge">42</span><span class="d-md-none">Messages</span></a> </li>
<li class="nav-item"> <a href="" class="nav-link"><i class="fa fa-bell" aria-hidden="true"></i> <span class="badge">42</span><span class="d-md-none">Notifications</span></a> </li>
<li class="nav-item"> <a href="#" class="nav-link"><i class="fa fa-question-circle" style="padding-right: 5px;"></i></a></li>
<li class="dropdown nav-item"> <a href="#" class="dropdown-toggle nav-link" data-toggle="dropdown" role="button"
aria-haspopup="true" aria-expanded="false"><i class="fa fa-user" aria-hidden="true"></i><span class="caret"></span><span class="d-md-none">Account</span></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="#" style="border-bottom: 1px solid #AEAEAE;">Change Password</a>
<a class="dropdown-item" href="#">Logout</a>
</div>
</li>
<li class="nav-item h-100"><a href="#" class="nav-link"><i class="fa fa-sign-out-alt"></i></a></li>
</ul>
</div>
</nav>
<div class="navbar-nav ml-sm-auto search-nav">
<div class="navbar-nav form-inline search-dropdown">
<div class="input-group input-group-sm form-inline">
<input type="text" class="form-control" aria-label="Text input with dropdown button">
<div class="input-group-append">
<button class="btn btn-default search-btn dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="font-size: 10pt;"> All Files <span class="caret"></span> </button>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="#" style="border-bottom: 1px solid #AEAEAE;">Location</a>
<a class="dropdown-item" href="#" style="border-bottom: 1px solid #AEAEAE;">Seller Name</a>
<a class="dropdown-item" href="#" style="border-bottom: 1px solid #AEAEAE;">File No.</a>
<a class="dropdown-item" href="#" style="border-bottom: 1px solid #AEAEAE;">Lookup No.</a>
<a class="dropdown-item" href="#">Policy No.</a>
</div>
</div>
</div>
</div>
</div>
<nav class="nav navbar-nav navbar-expand-lg navbar-default d-md-none fixed-top" style="padding-bottom:10px;">
<div class="navbar-brand mx-auto"> <a class="text-center" href="index.html"><img src="../images/logo-e-closing-dt.png" alt="E-Closing DT"></a> </div>
<div class="mx-auto">
<div class="navbar-nav form-inline search-dropdown ">
<div class="input-group input-group-sm form-inline">
<input type="text" class="form-control" aria-label="Text input with dropdown button">
<div class="input-group-append">
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false"> All Files <span class="caret"></span> </button>
<div class="dropdown-menu dropdown-menu-right"> <a class="dropdown-item" href="#" style="border-bottom: 1px solid #AEAEAE;">Location</a> <a class="dropdown-item" href="#" style="border-bottom: 1px solid #AEAEAE;">Seller Name</a> <a class="dropdown-item" href="#" style="border-bottom: 1px solid #AEAEAE;">File No.</a> <a class="dropdown-item" href="#" style="border-bottom: 1px solid #AEAEAE;">Lookup No.</a> <a class="dropdown-item" href="#">Policy No.</a> </div>
<!-- /btn-group -->
</div>
<!-- /input-group -->
</div>
</div>
</div>
</nav>
答案 0 :(得分:0)
自己解决。 Bootstrap.css稍作修改,并与边距进行交互。解决此问题后,媒体查询导致了其他一些奇怪的空白。清理了媒体查询,它现在可以在IE11和Edge中使用。因此,对于搜索此类奇怪问题的所有初级DEV,请检查您的媒体查询。