Bootstrap my learning record 3 navigation bar understanding, bootstrap navigation bar
The following theoretical content is copied from the Bootstrap Chinese Network (a good bootstrap learning website)
Navigation bar default style navigation bar
A navigation bar is a basic responsive component that serves as the navigation page header in your application or website. They can be folded (and turned off) on mobile devices and gradually become horizontally expanded when the width of the viewport increases.
The following code and comments are my understanding in the learning process:
(View the necessary. CSS and. js files)
1 <! DOCTYPE html> 2
Component Arrangement
Add.navbar-left
And.navbar-right
Tool class alignment navigation links, forms, buttons, or text. Both classes use CSS to set floating styles in a specific direction. For example, to align navigation links, place them in a separate tool class<ul>
Label.
These classes are.pull-left
And.pull-right
But they are limited to media query, which makes it easier to process the navigation bar components on screens of various sizes.
Align multiple components to the right
Navigation Bar currently does not support multiple.navbar-right
Class. In order to make appropriate gaps between the content.navbar-right
The element uses the negative margin (margin ). If multiple elements use this class, their margins (margin) cannot be displayed as expected.
We will review this feature when you rewrite this component in version v4.
Fixed on top
Add.navbar-fixed-top
Class allows the navigation bar to be fixed on the top and can contain.container
Or.container-fluid
Container to center the navigation bar and add inner padding on both sides ).
To
body
Padding in element settings)
This fixed navigation bar will cover other content on the page, unless you give<body>
The element is set at the bottom.padding
. You can use your own values or the code given below. Tip: the default height of the navigation bar is 50px.
body { padding-top: 70px; }
1 <nav class="navbar navbar-default navbar-fixed-top">2 <div class="container">3 ...4 </div>5 </nav>
Fixed at the bottom
Add.navbar-fixed-bottom
Class allows the navigation bar to be fixed at the bottom, and can also contain.container
Or.container-fluid
Container to center the navigation bar and add inner padding on both sides ).
To
body
Padding in element settings)
This fixed navigation bar will cover other content on the page, unless you give<body>
The element is set at the bottom.padding
. You can use your own values or the code given below. Tip: the default height of the navigation bar is 50px.
body { padding-bottom: 70px; }
1 <nav class="navbar navbar-default navbar-fixed-bottom">2 <div class="container">3 ...4 </div>5 </nav>
Rest on top
Add.navbar-static-top
Class to create a navigation bar with the width of the page, it will disappear as the page scrolls down. You can also include.container
Or.container-fluid
Container, used to align the navigation bar in the center and add inner padding on both sides ).
Add.navbar-static-top
Class to create a navigation bar with the width of the page, it will disappear as the page scrolls down. You can also include.container
Or.container-fluid
Container, used to align the navigation bar in the center and add inner padding on both sides ). To center and pad navbar content.
1 <nav class="navbar navbar-default navbar-static-top">2 <div class="container">3 ...4 </div>5 </nav>
Reversed navigation bar
Add.navbar-inverse
Class to change the appearance of the navigation bar.
1 <nav class="navbar navbar-inverse">2 ...3 </nav>