0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-02 14:24:19 +01:00
Bootstrap/docs/components/navbar.md

169 lines
4.3 KiB
Markdown
Raw Normal View History

2014-07-14 08:33:54 +02:00
---
layout: page
title: New navbar
---
2014-10-27 12:49:24 +01:00
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.
2014-07-14 08:33:54 +02:00
2014-10-27 12:49:24 +01:00
### Basics
Here's what you need to know before getting started with the navbar:
- Navbars require a wrapping `.navbar` and either a color scheme class or custom styles.
- When using multiple components in a navbar, some [alignment classes](#alignment) are required.
- Navbars and their contents are fluid by default. Use [optional containers](#containers) to limit their horizontal width.
### Branding
Name your company, product, or project with `.navbar-brand`.
{% example html %}
2014-07-14 08:33:54 +02:00
<div class="navbar navbar-default">
2014-10-27 12:49:24 +01:00
<h3 class="navbar-brand">
2014-07-14 08:33:54 +02:00
<a href="#">Navbar</a>
</h3>
</div>
2014-10-27 12:49:24 +01:00
{% endexample %}
### Navigation
Use `.nav-pills` within a navbar for basic navigation.
2014-07-14 08:33:54 +02:00
2014-10-27 12:49:24 +01:00
{% example html %}
2014-07-14 08:33:54 +02:00
<div class="navbar navbar-default">
2014-10-27 12:49:24 +01:00
<ul class="nav nav-pills">
2014-07-14 08:33:54 +02:00
<li class="nav-item active">
<a class="nav-link" href="#">Home</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>
</div>
2014-10-27 12:49:24 +01:00
{% endexample %}
### Inline forms
Add an `.inline-form` within the navbar with nearly any combination of form controls and buttons.
{% example html %}
<div class="navbar navbar-default">
<form class="form-inline">
<input class="form-control" type="text" placeholder="Search">
<button class="btn btn-primary" type="submit">Search</button>
</form>
</div>
{% endexample %}
### Containers
Although it's not required, you can wrap a navbar in a `.container` or add one within for basic horizontal control.
{% example html %}
<div class="navbar navbar-default">
<div class="container">
<h3 class="navbar-brand">
<a href="#">Navbar</a>
</h3>
</div>
</div>
{% endexample %}
{% example html %}
<div class="container">
<div class="navbar navbar-default">
<h3 class="navbar-brand">
<a href="#">Navbar</a>
</h3>
</div>
</div>
{% endexample %}
2014-07-14 08:33:54 +02:00
2014-10-27 12:49:24 +01:00
### Alignment
Use `.pull-left` or `.pull-right` to align multiple elements within the navbar.
{% example html %}
2014-07-14 08:33:54 +02:00
<div class="navbar navbar-default">
<h3 class="navbar-brand pull-left">
<a href="#">Navbar</a>
</h3>
<ul class="nav nav-pills pull-left">
<li class="nav-item active">
<a class="nav-link" href="#">Home</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>
<ul class="nav nav-pills pull-right">
<li class="nav-item">
<a class="nav-link" href="#">Help</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Sign out</a>
</li>
</ul>
</div>
2014-10-27 12:49:24 +01:00
{% endexample %}
2014-07-14 08:33:54 +02:00
2014-10-27 12:49:24 +01:00
### Inverse color scheme
Replace `.navbar-default` with `.navbar-inverse` for a darker background color and white text.
2014-07-14 08:33:54 +02:00
2014-10-27 12:49:24 +01:00
{% example html %}
2014-07-14 08:33:54 +02:00
<div class="navbar navbar-inverse">
<h3 class="navbar-brand pull-left">
<a href="#">Navbar</a>
</h3>
<ul class="nav nav-pills pull-left">
<li class="nav-item active">
<a class="nav-link" href="#">Home</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 pull-right">
2014-07-14 08:33:54 +02:00
<input class="form-control" type="text" placeholder="Search">
<button class="btn btn-primary" type="submit">Search</button>
</form>
</div>
2014-10-27 12:49:24 +01:00
{% endexample %}
2014-07-14 08:33:54 +02:00
2014-10-27 12:49:24 +01:00
### Collapsible content
2014-07-14 08:33:54 +02:00
2014-10-27 12:49:24 +01:00
Our collapse plugin allows you to use a `<button>` to toggle hidden content.
{% example html %}
2014-07-14 17:48:33 +02:00
<div class="collapse" id="navbar-header">
<div class="inverse p-a">
2014-07-14 08:33:54 +02:00
<h3>Collapsed content</h3>
<p>Toggleable via the navbar brand.</p>
</div>
2014-07-14 17:48:33 +02:00
</div>
<div class="navbar navbar-default">
2014-07-14 08:33:54 +02:00
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-header">
&#9776;
</button>
</div>
2014-10-27 12:49:24 +01:00
{% endexample %}