Bootstrap source code analysis: foRm, navbar 1, Form (foRm)
Source code file:
_ Form. scss
Mixins/_ form. scss
1. hierarchical classification: form-group-> form-control/input-group/form-static-control-> tags
2. Form-group/form-control/input-group/form-static-control containers can be displayed in two ways: block and inline-block. Table-cell is used to implement the input-group level.
.input-group { display: inline-table; vertical-align: middle; .input-group-addon, .input-group-btn, .form-control { width: auto; }}
3. Input-group-addon: If a webpage text icon is inserted into the class, it will be misplaced in the upper pixel.
Solution: The glyphicon cannot be used together with other styles, but is nested internally, because the glyphicon has a setting of 1 pixel for top:
.glyphicon { position: relative; top: 1px; display: inline-block; font-family: 'Glyphicons Halflings'; font-style: normal; font-weight: normal; line-height: 1; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;}
Ii. navigation bar (navbar)
Source code file:
_ Navbar. scss
1. Division of internal areas, such as head and other areas, and positioning of navigation bar positions.
2. Implement the folding device (removed in 4.0), that is, the navbar-collapse class, instead of collapse. A hidden layer is displayed on the button.
2.1. Navbar-collapse: It is forcibly displayed when it is greater than the breakpoint (because collapse is hidden by default)
3. Content support for nav, brand, form, and toggler
4. Navbar-toggler (4.0 removed): it is set to be displayed when the screen is smaller than the breakpoint value (768), and collapse is directly used to display this button at 4.0, with no screen size limit, navbar-toggle applications should also be used in combination with collapse
5. Navbar-static-top: adds zIndex and removes the rounded corner and Border width.
6. Navbar-fixed-top/bottom: both are positioned at the top and bottom, with floating Effects
7. Navbar-brand: brand, including webpage name and company Logo
8. Navbar-toggle: Click image used for shrinking. It will be displayed when it is smaller than breakpoint. If it is greater than this value, it will be hidden (and toggle will show right floating, as a relative positioning element ):
.navbar-toggle { position: relative; float: right; margin-right: $navbar-padding-horizontal; padding: 9px 10px; @include navbar-vertical-align(34px); background-color: transparent; background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214 border: 1px solid transparent; border-radius: $border-radius-base; // We remove the `outline` here, but later compensate by attaching `:hover` // styles to `:focus`. &:focus { outline: 0; } // Bars .icon-bar { display: block; width: 22px; height: 2px; border-radius: 1px; } .icon-bar + .icon-bar { margin-top: 4px; } @media (min-width: $grid-float-breakpoint) { display: none; }}
9. Navbar-nav: some compatibility settings have been made for the original nav, mainly for style adjustments under breakpoint-max and style adjustments under breakpointg, or remove the Default background color, shadow, and so on.
10. Navbar-form: Mainly adjusts that all forms are row elements.
11. Navbar-text and navbar-btn: all are compatible with the default settings.
12. Navbar provides two themes: default and inverse. Each topic has corresponding style compatibility processing for its parts.
13. The navigation bar does not have many styles. It only provides toggle and brand content. It mainly provides two themes and a combination of dropdown, collapse, form, and nav components.