gpt4 book ai didi

javascript - 带有可变和固定宽度按钮的 Bootstrap 导航栏?

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

我正在尝试使用 Bootstrap 制作一个导航栏,左侧有一个品牌 Logo ,中间有几个可变宽度的链接,右侧有一些固定宽度的按钮。我希望所有内容都在一行中,并且宽度可变的按钮刚好适合任何可用空间。

参见此处:https://jsfiddle.net/wfu6yxqd/

2 个固定宽度的按钮应该在可变宽度链接的右边

我不需要 Bootstrap 的内置导航栏折叠行为,所以在我的导航栏定义中不需要(我在某些屏幕尺寸下实现我自己的自定义折叠)

非常感谢您的帮助!

代码:

<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="navbar-header">
<a class="navbar-brand" href="#">Brand</a>

<ul class="nav nav-justified">
<li><a href="">Variable width link 1</a></li>
<li><a href="">Variable width link 2</a></li>
</ul>
</div>

<div> <!-- class="navbar-header" ?? -->
<a class="btn btn-xs btn-default">Fixed width button</a>
<div class="btn-group">
<button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">FW drop down&nbsp;&nbsp;<span class="caret"></span></button>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Menu item 1</a></li>
<li><a href="#">Menu item 2</a></li>
</ul>
</div>
</div>
</nav>

最佳答案

这是一种方法:您可以在 navbar-nav 部分之外/之后为您的按钮创建一个 div,并使该部分符合 navbar

*我保留了可折叠功能,因为我想您将拥有一些用于移动导航的东西,这些东西将有类似的元素可以解决。

看例子

body,
html {
margin-top: 75px;
}
.navbar.navbar-custom {
list-style: none;
background: #444;
line-height: 60px;
margin: 0;
height: 60px;
}
.navbar.navbar-custom .navi {
display: table;
width: 100%;
list-style: none;
text-align: center;
}
.navbar.navbar-custom .navi > li {
display: table-cell;
cursor: pointer;
}
.navbar.navbar-custom .navi > li > a {
text-align: center;
text-decoration: none;
color: #fff;
}
.navbar.navbar-custom .logo-brand {
margin-left: 15px;
color: #fff;
text-decoration: none;
}
.navbar.navbar-custom .btn-nav {
text-align: right;
}
.navbar.navbar-custom .btn-nav .btn.btn-black {
height: 50px;
border-radius: 0;
background: #444;
color: #fff;
border: none;
outline: none;
box-shadow: none;
}
.navbar-custom .btn-group .dropdown-menu,
.navbar-custom .btn-group .dropdown-menu:hover,
.navbar-custom .btn-group .dropdown-menu:focus {
left: auto;
right: 0;
border: none;
background: #444;
border-radius: 0;
}
.navbar-custom .btn-group .dropdown-menu > li > a {
color: #fff;
}
.navbar-custom .btn-group .dropdown-menu > li > a:hover {
background: #222;
}
.no-gutter >[class*='col-'] {
padding-right: 0;
padding-left: 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-custom navbar-fixed-top">
<div class="container-fluid">
<div class="row no-gutter">
<div class="col-xs-2"><a class="logo-brand" href="#">Logo Brand</a>

</div>
<div class="col-xs-8">
<ul class="navi">
<li><a href="#">Link 1</a>

</li>
<li><a href="#">Link 2</a>

</li>
</ul>
</div>
<div class="col-xs-2">
<div class="btn-nav">
<div class="btn-group" role="group" aria-label="...">
<button type="button" class="btn btn-black">1</button>
<div class="btn-group" role="group">
<button type="button" class="btn btn-black dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">2 <span class="caret"></span>

</button>
<ul class="dropdown-menu">
<li><a href="#">Button link 1</a>

</li>
<li><a href="#">Button link 1</a>

</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</nav>
<div class="container">
<p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up
one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum
et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section
1.10.32.Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia,
looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de
Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from
a line in section 1.10.32.Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College
in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33
of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes
from a line in section 1.10.32.Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney
College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32
and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit
amet..", comes from a line in section 1.10.32.Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor
at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from
sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem
ipsum dolor sit amet..", comes from a line in section 1.10.32.Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a
Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem
Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem
Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard
McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable
source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first
line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
</div>

关于javascript - 带有可变和固定宽度按钮的 Bootstrap 导航栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32951382/

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