gpt4 book ai didi

javascript - 以移动为中心的 Bootstrap 导航栏品牌

转载 作者:行者123 更新时间:2023-11-30 16:08:24 25 4
gpt4 key购买 nike

我想制作一个响应式网页和导航栏,我使用了 Bootstrap,我对品牌设置有一些疑问。我应该怎么做才能使导航栏品牌在桌面左侧和移动中心?我已经做了一个导航栏。

这是我的 html 代码。

<body id="mypage" data-spy="scroll" data-target=".navbar" data-offset="50" style="background-color:bisque">
<nav class="navbar navbar-inverse navbar-fixed-top ">
<div class="container-fluid navbar-left">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="http://localhost:59842/NNC.html">
logo
</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-left">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" style="background-color:black">
yes<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#">hello</a></li>
<li><a href="#">hello</a></li>
<li><a href="#">hello</a></li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" style="background-color:black">
no<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#">yes</a></li>
<li><a href="#">yes</a></li>
<li><a href="#">yes</a></li>
</ul>
</li>
</ul>
</div>
</nav>

最佳答案

试试这个:

@media screen and (max-width: 766px) {
nav a.navbar-brand{
position: absolute;
left: 50%;
transform: translateX(-50%);
}
}

@media screen and (max-width: 766px) {
nav a.navbar-brand{
position: absolute;
left: 50%;
transform: translateX(-50%);
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-inverse navbar-fixed-top ">
<div class="container-fluid navbar-left">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="http://localhost:59842/NNC.html">
logo
</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-left">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" style="background-color:black">
yes<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#">hello</a></li>
<li><a href="#">hello</a></li>
<li><a href="#">hello</a></li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" style="background-color:black">
no<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#">yes</a></li>
<li><a href="#">yes</a></li>
<li><a href="#">yes</a></li>
</ul>
</li>
</ul>
</div>
</nav>

关于javascript - 以移动为中心的 Bootstrap 导航栏品牌,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36663953/

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