我正在为自定义wordpress网站开发一个主题,目前正在构建一个三行导航栏。
我想知道,是否有可能“组合”前两个导航栏,以便我可以在两个组合导航栏的高度上有一个徽标,同时仍然保持列表项的分离?
这个问题has been asked before用于Bootstrap v3,但是我很难将解决方案映射到Bootstrap v4和新的flexbox和网格系统。
从我上面提到的问题复制,我基本上是想实现这个目标:
+-------------------------------------------------------------------------------+
| | Search Input Form |
| SITE LOGO |---------------------------------------------------------------+
| | Nav-B-1 Nav-B-2 Nav-B-3 Nav-B-4 |
+-------------------------------------------------------------------------------+
| Nav-C-1 Nav-C-2 Nav-C-3 Nav-C-4 Nav-C-5 |
+-------------------------------------------------------------------------------+
------Begin Body Content------
| |
V V
然后,如果可能的话,我希望将主导航缩小回移动设备和平板电脑上的单个导航栏,同时将所有菜单组合在一起,只需在一个汉堡菜单中搜索。说实话,我以为我在这个问题的第一部分迷失了,但第二部分让我更加慌张。
折叠导航(移动设备和平板电脑)
+---------------------------------------------------------------------------------+
| SITE LOGO | Hamburger Menu |
+---------------------------------------------------------------------------------+
| Search Input Form Search Button |
+---------------------------------------------------------------------------------+
扩展导航(移动设备和平板电脑)
+---------------------------------------------------------------------------------+
| SITE LOGO | Hamburger Menu |
+---------------------------------------------------------------------------------+
| Nav-B-1 |
| Nav-B-2 |
| Nav-B-3 |
| Nav-B-4 |
| --------------------------------------------------------------------------- |
| Nav-C-1 |
| Nav-C-2 |
| Nav-C-3 |
| Nav-C-4 |
| Nav-C-5 |
+---------------------------------------------------------------------------------+
---End Expanded Menu---
+---------------------------------------------------------------------------------+
| Search Input Form Search Button |
+---------------------------------------------------------------------------------+
这甚至可能吗?我想知道Bootstrap是不是这样的东西的正确框架:(
提前感谢您的帮助!!!
这是我到目前为止所做的事情:
@media screen and (min-width: 767px) {
.dropdown:hover>.dropdown-menu {
display: block;
}
}
@media screen and (max-width: 767px) {
.dropdown-toggle::after {
display: none;
}
}
@media screen and (max-width: 767px) {
nav#hide-on-mobile {
visibility: hidden;
clear: both;
display: none;
}
}
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
</head>
<body>
<nav id="hide-on-mobile" class="navbar navbar-expand-md navbar-light flex-row pb-0 pt-3">
<form class="form-inline ml-auto">
<input class="form-control form-control-sm mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-dark btn-sm my-2 my-sm-0" type="submit">Search</button>
</form>
</nav>
<nav class="navbar navbar-expand-md navbar-light flex-row">
<a class="navbar-brand mr-auto" href="<?php echo home_url(); ?>">
sandbox
</a>
<button class="navbar-toggler ml-lg-0" type="button" data-toggle="collapse" data-target="#navbarSupportedContent, #navbarSupportedContent2" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
</div>
</nav>
<nav class="navbar navbar-expand-md navbar-dark bg-dark py-0">
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
</div>
</nav>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
</body>