Bootstrap Navbar With Variable And Fixed Width Buttons?
I'm trying to make a navbar with Bootstrap that has a brand logo on the left, a couple of variable width links in the middle, and some fixed width buttons on the right. I want ever
Solution 1:
Here's one way to go: you can create a div outside/after the navbar-nav
section for your buttons and conform that section to the navbar
.
*I left the collapsible function in place since I image you'll have something for mobile navigation that will have similar elements to work around.
See example
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;
}
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script><linkhref="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"rel="stylesheet" /><navclass="navbar navbar-custom navbar-fixed-top"><divclass="container-fluid"><divclass="row no-gutter"><divclass="col-xs-2"><aclass="logo-brand"href="#">Logo Brand</a></div><divclass="col-xs-8"><ulclass="navi"><li><ahref="#">Link 1</a></li><li><ahref="#">Link 2</a></li></ul></div><divclass="col-xs-2"><divclass="btn-nav"><divclass="btn-group"role="group"aria-label="..."><buttontype="button"class="btn btn-black">1</button><divclass="btn-group"role="group"><buttontype="button"class="btn btn-black dropdown-toggle"data-toggle="dropdown"aria-haspopup="true"aria-expanded="false">2 <spanclass="caret"></span></button><ulclass="dropdown-menu"><li><ahref="#">Button link 1</a></li><li><ahref="#">Button link 1</a></li></ul></div></div></div></div></div></div></nav><divclass="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>
Solution 2:
How about this https://jsfiddle.net/t58f873j/
<div class="container-fluid">
<navclass="navbar navbar-inverse navbar-fixed-top"role="navigation"><divclass="row"><divclass="col-xs-2"><aclass="navbar-brand"href="#">Brand</a></div><divclass="col-xs-6 text-center"><ulclass="nav nav-justified"><li><ahref="">Variable width link 1</a></li><li><ahref="">Variable width link 2</a></li></ul></div><divclass="col-xs-4"><aclass="btn btn-xs btn-default">Fixed width button</a><divclass="btn-group"><buttontype="button"class="btn btn-xs btn-default dropdown-toggle"data-toggle="dropdown"aria-expanded="false">FW drop down <spanclass="caret"></span></button><ulclass="dropdown-menu"role="menu"><li><ahref="#">Menu item 1</a></li><li><ahref="#">Menu item 2</a></li></ul></div></div></div></nav>
Post a Comment for "Bootstrap Navbar With Variable And Fixed Width Buttons?"