gpt4 book ai didi

html - Bootstrap 折叠导航栏 - 我希望菜单左对齐但它右对齐

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

我制作了简单的 Bootstrap 导航栏,当显示窗口很小时它会折叠。我还在该导航栏中添加了图像。

现在,当我缩小浏览器窗口并出现汉堡包菜单时,我的可折叠菜单没有对齐到网页的最左侧,请参见下面的附图。

我想让可折叠菜单左对齐,我应该怎么做?

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

<nav class="navbar navbar-inverse navbar-static-top" role="navigation">
<div class="container-fluid">

<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#menu">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="index.html" class="navbar-left logo">
<img src="img/logo.png" height="40px">
</a>
<a class="navbar-brand text-hide" href="index.html">title</a>
</div>

<div class="collapse navbar-collapse navbar-left" id="menu">
<ul class="nav navbar-nav">
<li class="active">
<a href="index.html">Bio</a>
</li>
<li>
<a href="portfolio.html">Portfolio</a>
</li>
<li>
<a href="#">Freebies</a>
</li>
</ul>
</div>

</div>
</nav>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

提前致谢

Screenshot of my collapsed navabar issue

最佳答案

在您的 CSS 中使用媒体查询,这样它就不会改变移动 View 。

工作示例:

@media (min-width: 768px) {
.nav {
margin-left: 212px;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

<nav class="navbar navbar-inverse navbar-static-top" role="navigation">
<div class="container-fluid">

<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#menu">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>

<a href="#" class="navbar-left logo">
<img src="http://placehold.it/50x50/f00/fff" height="50px">
</a>

<a class="navbar-brand text-hide" href="#">title</a>
</div>

<div class="collapse navbar-collapse" id="menu">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Bio</a>
</li>
<li><a href="#">Portfolio</a>
</li>
<li><a href="#">Freebies</a>
</li>
</ul>
</div>

</div>
</nav>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

关于html - Bootstrap 折叠导航栏 - 我希望菜单左对齐但它右对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41613859/

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