mirror of
https://github.com/twbs/bootstrap.git
synced 2024-11-29 11:24:18 +01:00
rewrite navbar once more for lower key styles and a new take on modifiers for improved customization
This commit is contained in:
parent
d073a3beaa
commit
d6b6a20a0d
@ -4,7 +4,7 @@ title: Navbar
|
|||||||
group: components
|
group: components
|
||||||
---
|
---
|
||||||
|
|
||||||
The navbar is a simple wrapper for positioning branding, navigation, and other elements. It's easily extensible and, with the help of our collapse plugin, it can easily integrate offscreen content.
|
The navbar is a simple wrapper for positioning branding, navigation, and other elements into a concise navigation header. It's easily extensible and, with the help of our collapse plugin, it can easily integrate offscreen content.
|
||||||
|
|
||||||
## Contents
|
## Contents
|
||||||
|
|
||||||
@ -28,11 +28,12 @@ Navbars come with built-in support for a handful of sub-components. Mix and matc
|
|||||||
- `.navbar-brand` for your company, product, or project name
|
- `.navbar-brand` for your company, product, or project name
|
||||||
- `.navbar-nav` for a full-height and lightweight navigation (including support for dropdowns)
|
- `.navbar-nav` for a full-height and lightweight navigation (including support for dropdowns)
|
||||||
- `.navbar-form` for vertically centering default-sized inputs and buttons.
|
- `.navbar-form` for vertically centering default-sized inputs and buttons.
|
||||||
|
- `.navbar-toggler` for use with our collapse plugin and other navigation toggling behaviors.
|
||||||
|
|
||||||
Here's an example of all the sub-components included in a default, light navbar:
|
Here's an example of all the sub-components included in a default, light navbar:
|
||||||
|
|
||||||
{% example html %}
|
{% example html %}
|
||||||
<nav class="navbar navbar-default">
|
<nav class="navbar navbar-light bg-faded">
|
||||||
<a class="navbar-brand" href="#">Navbar</a>
|
<a class="navbar-brand" href="#">Navbar</a>
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li class="nav-item active">
|
<li class="nav-item active">
|
||||||
@ -55,12 +56,14 @@ Here's an example of all the sub-components included in a default, light navbar:
|
|||||||
</nav>
|
</nav>
|
||||||
{% endexample %}
|
{% endexample %}
|
||||||
|
|
||||||
## Inverse theme
|
## Color schemes
|
||||||
|
|
||||||
When you want a darker navbar with light text colors, replace the `.navbar-default` with `.navbar-inverse`.
|
Theming the navbar has never been easier thanks to the combination of a simple link color modifier class and `background-color` utilities. Put another way, you specify light or dark and apply a background color.
|
||||||
|
|
||||||
{% example html %}
|
Here are some examples to show what we mean.
|
||||||
<nav class="navbar navbar-inverse">
|
|
||||||
|
<div class="bd-example">
|
||||||
|
<nav class="navbar navbar-dark bg-inverse">
|
||||||
<a class="navbar-brand" href="#">Navbar</a>
|
<a class="navbar-brand" href="#">Navbar</a>
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li class="nav-item active">
|
<li class="nav-item active">
|
||||||
@ -78,10 +81,66 @@ When you want a darker navbar with light text colors, replace the `.navbar-defau
|
|||||||
</ul>
|
</ul>
|
||||||
<form class="form-inline navbar-form pull-right">
|
<form class="form-inline navbar-form pull-right">
|
||||||
<input class="form-control" type="text" placeholder="Search">
|
<input class="form-control" type="text" placeholder="Search">
|
||||||
<button class="btn btn-success-outline" type="submit">Search</button>
|
<button class="btn btn-info-outline" type="submit">Search</button>
|
||||||
</form>
|
</form>
|
||||||
|
</nav>
|
||||||
|
<nav class="navbar navbar-dark bg-primary">
|
||||||
|
<a class="navbar-brand" href="#">Navbar</a>
|
||||||
|
<ul class="nav navbar-nav">
|
||||||
|
<li class="nav-item active">
|
||||||
|
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="#">Features</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="#">Pricing</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="#">About</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<form class="form-inline navbar-form pull-right">
|
||||||
|
<input class="form-control" type="text" placeholder="Search">
|
||||||
|
<button class="btn btn-secondary-outline" type="submit">Search</button>
|
||||||
|
</form>
|
||||||
|
</nav>
|
||||||
|
<nav class="navbar navbar-light" style="background-color: #e3f2fd;">
|
||||||
|
<a class="navbar-brand" href="#">Navbar</a>
|
||||||
|
<ul class="nav navbar-nav">
|
||||||
|
<li class="nav-item active">
|
||||||
|
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="#">Features</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="#">Pricing</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="#">About</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<form class="form-inline navbar-form pull-right">
|
||||||
|
<input class="form-control" type="text" placeholder="Search">
|
||||||
|
<button class="btn btn-primary-outline" type="submit">Search</button>
|
||||||
|
</form>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% highlight html %}
|
||||||
|
<nav class="navbar navbar-dark bg-inverse">
|
||||||
|
<!-- Navbar content -->
|
||||||
</nav>
|
</nav>
|
||||||
{% endexample %}
|
|
||||||
|
<nav class="navbar navbar-dark bg-primary">
|
||||||
|
<!-- Navbar content -->
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<nav class="navbar navbar-light" style="background-color: #e3f2fd;">
|
||||||
|
<!-- Navbar content -->
|
||||||
|
</nav>
|
||||||
|
{% endhighlight %}
|
||||||
|
|
||||||
## Containers
|
## Containers
|
||||||
|
|
||||||
@ -89,14 +148,14 @@ Although it's not required, you can wrap a navbar in a `.container` to center it
|
|||||||
|
|
||||||
{% example html %}
|
{% example html %}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<nav class="navbar navbar-default">
|
<nav class="navbar navbar-light bg-faded">
|
||||||
<a class="navbar-brand" href="#">Navbar</a>
|
<a class="navbar-brand" href="#">Navbar</a>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
{% endexample %}
|
{% endexample %}
|
||||||
|
|
||||||
{% example html %}
|
{% example html %}
|
||||||
<nav class="navbar navbar-default">
|
<nav class="navbar navbar-light bg-faded">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<a class="navbar-brand" href="#">Navbar</a>
|
<a class="navbar-brand" href="#">Navbar</a>
|
||||||
</div>
|
</div>
|
||||||
@ -109,12 +168,12 @@ Our collapse plugin allows you to use a `<button>` or `<a>` to toggle hidden con
|
|||||||
|
|
||||||
{% example html %}
|
{% example html %}
|
||||||
<div class="collapse" id="exCollapsingNavbar">
|
<div class="collapse" id="exCollapsingNavbar">
|
||||||
<div class="inverse p-a">
|
<div class="bg-inverse p-a">
|
||||||
<h4>Collapsed content</h4>
|
<h4>Collapsed content</h4>
|
||||||
<span class="text-muted">Toggleable via the navbar brand.</span>
|
<span class="text-muted">Toggleable via the navbar brand.</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<nav class="navbar navbar-default">
|
<nav class="navbar navbar-light bg-faded">
|
||||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#exCollapsingNavbar">
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#exCollapsingNavbar">
|
||||||
☰
|
☰
|
||||||
</button>
|
</button>
|
||||||
@ -124,7 +183,7 @@ Our collapse plugin allows you to use a `<button>` or `<a>` to toggle hidden con
|
|||||||
For more complex navbar patterns, like those used in Bootstrap v3, use the `.navbar-toggleable-*` classes in conjunction with the `.navbar-toggler`. These classes override our responsive utilities to show navigation only when content is meant to be shown.
|
For more complex navbar patterns, like those used in Bootstrap v3, use the `.navbar-toggleable-*` classes in conjunction with the `.navbar-toggler`. These classes override our responsive utilities to show navigation only when content is meant to be shown.
|
||||||
|
|
||||||
{% example html %}
|
{% example html %}
|
||||||
<nav class="navbar navbar-default">
|
<nav class="navbar navbar-light bg-faded">
|
||||||
<button class="navbar-toggler hidden-sm-up" type="button" data-toggle="collapse" data-target="#exCollapsingNavbar2">
|
<button class="navbar-toggler hidden-sm-up" type="button" data-toggle="collapse" data-target="#exCollapsingNavbar2">
|
||||||
☰
|
☰
|
||||||
</button>
|
</button>
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
.navbar {
|
.navbar {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
padding: $navbar-padding-vertical $navbar-padding-horizontal;
|
||||||
@include clearfix;
|
@include clearfix;
|
||||||
|
|
||||||
@include media-breakpoint-up(sm) {
|
@include media-breakpoint-up(sm) {
|
||||||
@ -69,13 +70,12 @@
|
|||||||
|
|
||||||
.navbar-brand {
|
.navbar-brand {
|
||||||
float: left;
|
float: left;
|
||||||
padding: .95rem 1rem;
|
margin-right: 1rem;
|
||||||
|
padding-top: .25rem;
|
||||||
|
padding-bottom: .25rem;
|
||||||
font-size: $font-size-lg;
|
font-size: $font-size-lg;
|
||||||
line-height: 1;
|
|
||||||
color: $navbar-default-brand-color;
|
|
||||||
|
|
||||||
@include hover-focus {
|
@include hover-focus {
|
||||||
color: $navbar-default-brand-hover-color;
|
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,11 +92,8 @@
|
|||||||
|
|
||||||
.navbar-toggler {
|
.navbar-toggler {
|
||||||
padding: .5rem .75rem;
|
padding: .5rem .75rem;
|
||||||
margin-top: .375rem;
|
|
||||||
margin-bottom: .375rem;
|
|
||||||
font-size: $font-size-lg;
|
font-size: $font-size-lg;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
color: $navbar-default-link-color;
|
|
||||||
background: none;
|
background: none;
|
||||||
border: $border-width solid transparent;
|
border: $border-width solid transparent;
|
||||||
@include border-radius($btn-border-radius);
|
@include border-radius($btn-border-radius);
|
||||||
@ -132,83 +129,26 @@
|
|||||||
|
|
||||||
.nav-link {
|
.nav-link {
|
||||||
display: block;
|
display: block;
|
||||||
padding: .95rem .75rem;
|
padding: .425rem .5rem;
|
||||||
line-height: 1.25; // Match the `.navbar-brand`
|
|
||||||
color: $navbar-default-link-color;
|
|
||||||
|
|
||||||
@include hover-focus {
|
|
||||||
color: $navbar-default-link-hover-color;
|
|
||||||
background-color: $navbar-default-link-hover-bg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.open > .nav-link,
|
|
||||||
.active > .nav-link,
|
|
||||||
.nav-link.open,
|
|
||||||
.nav-link.active {
|
|
||||||
@include plain-hover-focus {
|
|
||||||
color: $navbar-default-link-active-color;
|
|
||||||
cursor: default;
|
|
||||||
background-color: $navbar-default-link-active-bg;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dark links against a light background
|
||||||
// Forms
|
.navbar-light {
|
||||||
//
|
|
||||||
// Additional modifier class to add to `.form-inline` to vertically center forms.
|
|
||||||
|
|
||||||
.navbar-form {
|
|
||||||
margin-top: .375rem;
|
|
||||||
margin-bottom: .375rem;
|
|
||||||
margin-right: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Alternate navbars
|
|
||||||
//
|
|
||||||
|
|
||||||
// todo: audit these styles
|
|
||||||
|
|
||||||
// Default navbar
|
|
||||||
.navbar-default {
|
|
||||||
background-color: $navbar-default-bg;
|
|
||||||
border-color: $navbar-default-border;
|
|
||||||
|
|
||||||
.navbar-brand {
|
.navbar-brand {
|
||||||
color: $navbar-default-brand-color;
|
color: $navbar-light-active-color;
|
||||||
|
|
||||||
@include hover-focus {
|
@include hover-focus {
|
||||||
color: $navbar-default-brand-hover-color;
|
color: $navbar-light-active-color;
|
||||||
background-color: $navbar-default-brand-hover-bg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inverse navbar
|
|
||||||
|
|
||||||
.navbar-inverse {
|
|
||||||
background-color: $navbar-inverse-bg;
|
|
||||||
border-color: $navbar-inverse-border;
|
|
||||||
|
|
||||||
.navbar-brand {
|
|
||||||
color: $navbar-inverse-brand-color;
|
|
||||||
|
|
||||||
@include hover-focus {
|
|
||||||
color: $navbar-inverse-brand-hover-color;
|
|
||||||
background-color: $navbar-inverse-brand-hover-bg;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar-nav {
|
.navbar-nav {
|
||||||
.nav-link {
|
.nav-link {
|
||||||
color: $navbar-inverse-link-color;
|
color: $navbar-light-color;
|
||||||
|
|
||||||
@include hover-focus {
|
@include hover-focus {
|
||||||
color: $navbar-inverse-link-hover-color;
|
color: $navbar-light-hover-color;
|
||||||
background-color: $navbar-inverse-link-hover-bg;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,13 +157,38 @@
|
|||||||
.nav-link.open,
|
.nav-link.open,
|
||||||
.nav-link.active {
|
.nav-link.active {
|
||||||
@include plain-hover-focus {
|
@include plain-hover-focus {
|
||||||
color: $navbar-inverse-link-active-color;
|
color: $navbar-light-active-color;
|
||||||
background-color: $navbar-inverse-link-active-bg;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// White links against a dark background
|
||||||
|
.navbar-dark {
|
||||||
|
.navbar-brand {
|
||||||
|
color: $navbar-dark-active-color;
|
||||||
|
|
||||||
|
@include hover-focus {
|
||||||
|
color: $navbar-dark-active-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.navbar-toggler {
|
.navbar-nav {
|
||||||
color: $navbar-inverse-link-color;
|
.nav-link {
|
||||||
|
color: $navbar-dark-color;
|
||||||
|
|
||||||
|
@include hover-focus {
|
||||||
|
color: $navbar-dark-hover-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.open > .nav-link,
|
||||||
|
.active > .nav-link,
|
||||||
|
.nav-link.open,
|
||||||
|
.nav-link.active {
|
||||||
|
@include plain-hover-focus {
|
||||||
|
color: $navbar-dark-active-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,56 +336,20 @@ $zindex-modal: 1050 !default;
|
|||||||
|
|
||||||
|
|
||||||
// Navbar
|
// Navbar
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
// Basics of a navbar
|
|
||||||
$navbar-margin-bottom: $spacer-y !default;
|
|
||||||
$navbar-border-radius: $border-radius !default;
|
$navbar-border-radius: $border-radius !default;
|
||||||
$navbar-padding-horizontal: $spacer !default;
|
$navbar-padding-horizontal: $spacer !default;
|
||||||
$navbar-padding-vertical: ($spacer / 2) !default;
|
$navbar-padding-vertical: ($spacer / 2) !default;
|
||||||
|
|
||||||
$navbar-default-color: #777 !default;
|
$navbar-dark-color: rgba(255,255,255,.5);
|
||||||
$navbar-default-bg: #f8f8f8 !default;
|
$navbar-dark-hover-color: rgba(255,255,255,.75);
|
||||||
$navbar-default-border: darken($navbar-default-bg, 6.5%) !default;
|
$navbar-dark-active-color: rgba(255,255,255,1);
|
||||||
|
$navbar-dark-disabled-color: rgba(255,255,255,.25);
|
||||||
|
|
||||||
$navbar-default-link-color: #777 !default;
|
$navbar-light-color: rgba(0,0,0,.3);
|
||||||
$navbar-default-link-hover-color: #555 !default;
|
$navbar-light-hover-color: rgba(0,0,0,.6);
|
||||||
$navbar-default-link-hover-bg: transparent !default;
|
$navbar-light-active-color: rgba(0,0,0,.8);
|
||||||
$navbar-default-link-active-color: #333 !default;
|
$navbar-light-disabled-color: rgba(0,0,0,.15);
|
||||||
$navbar-default-link-active-bg: darken($navbar-default-bg, 5%) !default;
|
|
||||||
$navbar-default-link-disabled-color: #ccc !default;
|
|
||||||
$navbar-default-link-disabled-bg: transparent !default;
|
|
||||||
|
|
||||||
$navbar-default-brand-color: $navbar-default-link-color !default;
|
|
||||||
$navbar-default-brand-hover-color: $navbar-default-link-hover-color !default;
|
|
||||||
$navbar-default-brand-hover-bg: transparent !default;
|
|
||||||
|
|
||||||
$navbar-default-toggle-hover-bg: #ddd !default;
|
|
||||||
$navbar-default-toggle-icon-bar-bg: #888 !default;
|
|
||||||
$navbar-default-toggle-border-color: #ddd !default;
|
|
||||||
|
|
||||||
|
|
||||||
// Inverted navbar
|
|
||||||
$navbar-inverse-color: lighten($gray-light, 12%) !default;
|
|
||||||
$navbar-inverse-bg: #373a3c !default;
|
|
||||||
$navbar-inverse-border: darken($navbar-inverse-bg, 10%) !default;
|
|
||||||
|
|
||||||
$navbar-inverse-link-color: lighten($gray-light, 15%) !default;
|
|
||||||
$navbar-inverse-link-hover-color: #fff !default;
|
|
||||||
$navbar-inverse-link-hover-bg: transparent !default;
|
|
||||||
$navbar-inverse-link-active-color: $navbar-inverse-link-hover-color !default;
|
|
||||||
$navbar-inverse-link-active-bg: darken($navbar-inverse-bg, 10%) !default;
|
|
||||||
$navbar-inverse-link-disabled-color: #444 !default;
|
|
||||||
$navbar-inverse-link-disabled-bg: transparent !default;
|
|
||||||
|
|
||||||
$navbar-inverse-brand-color: $navbar-inverse-link-color !default;
|
|
||||||
$navbar-inverse-brand-hover-color: #fff !default;
|
|
||||||
$navbar-inverse-brand-hover-bg: transparent !default;
|
|
||||||
|
|
||||||
$navbar-inverse-toggle-hover-bg: #333 !default;
|
|
||||||
$navbar-inverse-toggle-icon-bar-bg: #fff !default;
|
|
||||||
$navbar-inverse-toggle-border-color: #333 !default;
|
|
||||||
|
|
||||||
|
|
||||||
// Navs
|
// Navs
|
||||||
|
Loading…
Reference in New Issue
Block a user