gpt4 book ai didi

css - 如何在 Bootstrap 3.3 中更改 Navbar 汉堡包断点

转载 作者:太空宇宙 更新时间:2023-11-04 06:17:18 26 4
gpt4 key购买 nike

我让 Bootstrap 3 导航在不同的断点处折叠到汉堡菜单,以避免它换行。

当前:bad所需:bad

我尝试粘贴各种答案中推荐的 CSS 解决方案:Change Navbar breakpoint in Bootstrap 3.3.2Change bootstrap navbar collapse breakpoint without using LESS .

上面第一个链接的最佳答案是:nogoog

问题:

  • 它看起来像一个已部署的汉堡菜单。我期待点击一个汉堡包图标,如上面的“所需”图像。
  • .navbar-right 元素(“市场、购物车图标等”)右对齐,位于菜单之外。 (见上图右下角)

body {
background: #f0f0f0;
}

.navbar {
border: none;
}

.dropdown-menu {
background-color: #f5f5f5;
}

.navbar-header {
background-color: #3a7dbb;
}
.collapse.navbar-collapse.js-navbar-collapse {
background-color: #3a7dbb;
}

.navbar-default .navbar-nav > li > a.dropdown-toggle {
font-family: "Oswald",Helvetica,Arial,sans-serif;
font-size: 18px;
color: white;
}

.dropdown > .dropdown-menu > li > a {
font-size: 16px;
}

.glyphicon-shopping-cart:before {
color: white;
}

.navbar .navbar-brand {
padding-top: 0px;
}

.navbar .navbar-brand > img{
height: 100%;
}

.dropdown > .dropdown-menu > li > a:hover {
background-color: white;
}

.navbar-nav > li > .dropdown-menu {
background-color: #f5f5f5;
margin-top: 20px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}

.navbar-default .navbar-nav > li > a {
/* width: 8em; */
font-weight: bold;
}

.mega-dropdown {
position: static !important;
width: 100%;
}

.mega-dropdown-menu {
padding: 20px 0px;
width: 100%;
box-shadow: none;
-webkit-box-shadow: none;
}

.center {
margin: auto;
}

.mega-dropdown-menu > li > ul {
padding: 0;
margin: 0;
}

.mega-dropdown-menu > li > ul > li {
list-style: none;
}

.mega-dropdown-menu > li > ul > li > a {
display: block;
padding: 3px 20px;
clear: both;
font-weight: normal;
line-height: 1.428571429;
color: #262626;
white-space: normal;
}

.mega-dropdown-menu > li ul > li > a {
font-size: 16px;
}

.mega-dropdown-menu > li ul > li > a:hover,
.mega-dropdown-menu > li ul > li > a:focus {
text-decoration: none;
color: #444;
background-color: white;
}

li.dropdown:hover {
background-color: #c3c1c1;
}

ul.dropdown-menu.mega-dropdown-menu.row {
width: 80%;
left: 0;
right: 0;
margin: 0 auto; /* Centers the element */
}

.mega-dropdown-menu .dropdown-header {
color: #428bca;
font-size: 18px;
font-weight: bold;
}

.mega-dropdown-menu .dropdown-header > a {
color: #428bca;
font-size: 18px;
font-weight: bold;
padding-left: 0;
}

.mega-dropdown-menu form {
margin: 3px 20px;
}

.mega-dropdown-menu .form-group {
margin-bottom: 3px;
}

.navbar-default .navbar-nav .open .dropdown-menu > li > a {
color: black !important;
}

/* .mega-dropdown-menu:before {
content: "";
border-bottom: 15px solid #fff;
border-right: 17px solid transparent;
border-left: 17px solid transparent;
position: absolute;
top: -15px;
left: 285px;
z-index: 10;
}

.mega-dropdown-menu:after {
content: "";
border-bottom: 17px solid #ccc;
border-right: 19px solid transparent;
border-left: 19px solid transparent;
position: absolute;
top: -17px;
left: 283px;
z-index: 8;
} */

.dropdown:hover .dropdown-menu {
display: block;
margin-top: 0; // remove the gap so it doesnt close
}
#main_pnlSiteTemplateHeader {
background-color: white;
padding-left: 0px;
padding-right: 0px;
}
#main_content_Content {
padding-top: 80px;
}
#main_content_TopBanner {
padding-top: 80px;
}

ul.dropdown-menu.mega-dropdown-menu.row {
top: 49px;
}

@media only screen and (min-width: 768px) {
.dropdown:hover > .dropdown-menu {
display: block;
}

.dropdown > .dropdown-toggle:active {
pointer-events: none;
}
}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Oswald|Open+Sans:400,400italic,600italic,600">
<!------ Include the above in your HEAD tag ---------->
<div class="">
<nav class="navbar navbar-default navbar-fixed-top">
<div class="navbar-header">
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".js-navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img src="http://www.hibarnsley.com/wp-content/uploads/2017/06/dummy-logo.png"></a>
</div>
<div class="collapse navbar-collapse js-navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown mega-dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">About<span class="caret"></span></a>
<ul class="dropdown-menu mega-dropdown-menu row">
<li class="col-sm-4">
<ul>
<li class="dropdown-header"><a href="#">Business Relationship Management</a></li>
<li><a href="#">Capability</a></li>
<li><a href="#">Role</a></li>
<li><a href="#">Discipline</a></li>
<li><a href="#">Philosophy</a></li>
</ul>
</li>
<li class="col-sm-4">
<ul>
<li class="dropdown-header"><a href="#">Institute</a></li>
<li class="divider"></li>
<li class="dropdown-header"><a href="#">Policies</a></li>
<li class="divider"></li>
<li class="dropdown-header"><a href="#">Registered Providers</a></li>
<li class="divider"></li>
<li class="dropdown-header"><a href="#">Strategic Alliances</a></li>
</ul>
</li>
<li class="col-sm-4">
<ul>
<li class="dropdown-header"><a href="#">Member-Based Leadership</a></li>
<li class="divider"></li>
<li class="dropdown-header"><a href="#">Board of Directors</a></li>
<li class="divider"></li>
<li class="dropdown-header"><a href="#">Knowledge Team</a></li>
<li class="divider"></li>
<li class="dropdown-header"><a href="#">Executive Council</a></li>
<li class="divider"></li>
<li class="dropdown-header"><a href="#">Council</a></li>
<li class="divider"></li>
<li class="dropdown-header"><a href="#">Regional Ambassadors</a></li>
</ul>
</li>
</ul>
</li>
</ul>

<ul class="nav navbar-nav">
<li class="dropdown mega-dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Resources<span class="caret"></span></a>
<ul class="dropdown-menu mega-dropdown-menu row">
</li>
</ul>
</li>
</ul>

<ul class="nav navbar-nav">
<li class="dropdown mega-dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Learning<span class="caret"></span></a>
<ul class="dropdown-menu mega-dropdown-menu row">
</ul>
</li>
</ul>
<ul class="nav navbar-nav">
<li class="dropdown mega-dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Programs<span class="caret"></span></a>
<ul class="dropdown-menu mega-dropdown-menu row">

</ul>
</li>
</ul>
<ul class="nav navbar-nav">
<li class="dropdown mega-dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Career<span class="caret"></span></a>
<ul class="dropdown-menu mega-dropdown-menu row">

</ul>
</li>
</ul>
<ul class="nav navbar-nav">
<li class="dropdown mega-dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Membership<span class="caret"></span></a>
<ul class="dropdown-menu mega-dropdown-menu row">
</ul>
</li>
</ul>

<ul class="nav navbar-nav navbar-right">
<li class="dropdown"><a class="dropdown-toggle" href="#">Marketplace<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="/books">Publications</a></li>
<li><a href="/memberships">Memberships</a></li>
<li><a href="/events">Events</a></li>
<li class="divider"></li>
<li><a href="/brm-marketplace">Full Marketplace</a></li>
</ul>
</li>
<li><a href="/brm-cart"><span class="glyphicon glyphicon-shopping-cart"></span></a></li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-question-sign"></span><span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">FAQs</a></li>
<li><a href="#">Intellectual Property Request</a></li>
<li><a href="#">Contact BRM Institute</a></li>
</ul>
</li>
<ul class="nav navbar-nav">
<li class="dropdown mega-dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-user"></span> Sign Up</a>
</li>
</ul>
<ul class="nav navbar-nav">
<li class="dropdown mega-dropdown">
<a href="http://brmi.mpxstage.com/account/login.aspx" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-log-in"></span> Login</a>
</li>
</ul>
</ul>
</div>
</nav>
</div>

谢谢!

最佳答案

解决您的问题的最干净的方法是根据您的要求自定义 Bootstrap 库。在 bootstrap 3.3 中,这是可能的。请参阅此链接 https://getbootstrap.com/docs/3.4/customize/ .请参阅变量“@grid-float-breakpoint”(导航栏未折叠的点)。为它设置的默认值为“@screen-sm-min”,根据您的要求修改它,如“@screen-lg-min”。编译并下载 Bootstrap 库并将其包含在您的 index.html 中。它将以最干净的方式解决您的所有问题。

关于css - 如何在 Bootstrap 3.3 中更改 Navbar 汉堡包断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55822292/

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