gpt4 book ai didi

html - 可折叠导航栏上的 Bootstrap 标题调整

转载 作者:行者123 更新时间:2023-11-28 02:19:25 26 4
gpt4 key购买 nike

JS fiddle 链接

https://jsfiddle.net/9dumrg8v/1/

这是我当前标题的外观 header

我有几个想要实现的目标:

<强>1。将可折叠栏和图像保持在同一行

当它调整到较小的窗口时,我想将它“锁定”在一条线上:

img

图像和可折叠栏是分开的,因为我没有在下拉列表中包含图像

  <a class="navbar-brand" href="main">
<img src="img/logo_header.png" class="img-responsive img-header" width="200">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
</div>

<强>2。在可折叠导航栏中包含底部的链接

让列表(一到六)在出现时与导航栏一起出现,目前它们是分开的。

excluded nav

此外,如果我尝试将它添加到 <div class="collapse navbar-collapse" id="navbarSupportedContent"> 中, 它被包含在同一行中并破坏了设计。

<div class="collapse navbar-collapse" id="navbarSupportedContent">
<div class="mwc-orange-nav">
<div class="container">
<div class="row px-4">
<div class="col text-center dropdown menu-holder menu-box pb-2 pt-2">
<a href="" class="menu-header">
One</a>
</div>
<div class="col text-center dropdown menu-holder menu-box pb-2 pt-2">
<a href="" class="menu-header">
Two</a>
</div>
<div class="col text-center dropdown menu-holder menu-box pb-2 pt-2">
<a href="" class="menu-header">
Three</a>
</div>
<div class="col text-center dropdown menu-holder menu-box pb-2 pt-2">
<a href="" class="menu-header">
Four</a>
</div>
<div class="col text-center dropdown menu-holder menu-box pb-2 pt-2">
<a href="" class="menu-header">
Five</a>
</div>
<div class="col text-center dropdown menu-holder menu-box pb-2 pt-2">
<a href="" class="menu-header">
Six</a>
</div>
</div>
</div>
</div>

collapsible navbar error

如有任何帮助,我们将不胜感激。

最佳答案

请尝试此代码。我们稍微改变了结构。

.navbar.navbar-expand-md.navbar-light { padding: 0; flex-direction: column; -webkit-flex-direction: column; }
.menu-top .login-btn { padding: 0 10px;}
.navbar-expand-md > .container > div { width: 100%; }
.menu-top { display: flex; display:-webkit-flex; align-items: center; -webkit-align-items: center;}
.navbar-expand-md .navbar-collapse { width:100%;}
.menu-box {
padding: 0px 45px;
}

.menu-box a {
color: white !important;
}

.menu-box:hover {
background-color: white;
}

.menu-box:hover a {
color: #f08400 !important;
text-decoration: none;
}

.mwc-orange-nav {
background-color: rgb(240,132,0, 0.8);
}

.bg-blue{
background: #00a6a6 !important;
border-color: #00a6a6 !important;
}

.curve-right {
border-top-right-radius: 10px !important;
border-bottom-right-radius: 10px !important;
}

.fa-search {
color:
#fff !important;
}

.header-font {
font-size: 18px;
color: #00a6a6;
}

.header-font:hover {
text-decoration: none;
color: #007070;
}

.header-box {
box-sizing: content-box;
padding: 5px 25px;
border-radius: 10px;
border: 2px solid #00a6a6;
color: #00a6a6;
}

.header-box:hover {
text-decoration: none;
color: white;
background-color: #00a6a6;
}

@media(max-width:767px){
.menu-top { padding: 0 10px; display: block; }
.menu-box { flex-basis: auto; -webkit-flex-basis: auto; }
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<div class="nav-header"> <!-- start header -->
<nav class="navbar navbar-expand-md navbar-light">
<div class="container pt-3">
<div class="menu-top">
<a class="navbar-brand" href="main">
<img src="https://www.webkit.org/blog-files/acid3-100.png" class="img-fluid" width="200">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<form action="cards/search.php" method="POST" class="d-inline w-50 mx-auto">
<div class="input-group">
<input type="text" name="text-search" id="searchBox" class="form-control search-bar" aria-label="Default" aria-describedby="inputGroup-sizing-default" placeholder="Search" required>
<div class="input-group-prepend">
<button type="submit" name="submit-search" class="input-group-text bg-blue curve-right"> <i class="fas fa-search"></i> </button>
</div>
</div>
<div id="response" class="scrollbar-design search-content"></div>
</form>
<div class="row login-btn">
<div class="col-md-6 mb-2 mt-2">
<a href="cards/index.php" class="header-font">Login</a>
</div>
<div class="col-md-6 mb-2 mt-2">
<a href="cards/register.php" class="header-box">Register</a>
</div>
</div>
</div>
</div>
<div class="collapse navbar-collapse mwc-orange-nav" id="navbarSupportedContent">
<div class="container">
<ul class="navbar-nav row px-4">
<li class="nav-item col text-center dropdown menu-holder menu-box pb-2 pt-2 active">
<a href="cards/list-new.php" class=" nav-link menu-header">
One</a>
</li>
<li class="nav-item col text-center dropdown menu-holder menu-box pb-2 pt-2">
<a href="cards/list.php?tn=beauty" class="nav-link menu-header">
Two</a>
</li>
<li class="nav-item col text-center dropdown menu-holder menu-box pb-2 pt-2">
<a href="cards/list.php?tn=health" class="nav-link menu-header">
Three</a>
</li>
<li class="nav-item col text-center dropdown menu-holder menu-box pb-2 pt-2">
<a href="cards/list.php?tn=wellness" class="nav-link menu-header">
Four</a>
</li>
<li class="nav-item col text-center dropdown menu-holder menu-box pb-2 pt-2">
<a href="cards/list-partners.php" class="nav-link menu-header">
Five</a>
</li>
<li class="nav-item col text-center dropdown menu-holder menu-box pb-2 pt-2">
<a href="articles" class="nav-link menu-header">
Six</a>
</li>
</ul>
</div>
</div>
</nav>
</div><!-- end header-->

关于html - 可折叠导航栏上的 Bootstrap 标题调整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58811709/

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