bootstrap源码分析之foRm、navbar
一、表单(Form)
源码文件:
_form.scss
mixins/_form.scss
1、按层次结构分:form-group -> form-control/input-group/form-static-control -> 各类标签
2、Form-group/form-control/input-group/form-static-control之类的容器,分为两种显示方式:block、inline-block。而实现input-group水平用的是table-cell。<span style="color: #800000;">.input-group </span>{<span style="color: #ff0000;"> display</span>:<span style="color: #0000ff;"> inline-table</span>;<span style="color: #ff0000;"> vertical-align</span>:<span style="color: #0000ff;"> middle</span>;<span style="color: #ff0000;"> .input-group-addon, .input-group-btn, .form-control { width</span>:<span style="color: #0000ff;"> auto</span>; }<span style="color: #800000;"> }</span>Copy after login3、Input-group-addon:类如果插入网页文字图标,会向上一个像素的错位
解决方案:glyphicon不能与其他样式合并使用,而是内部嵌套使用即可,因为glyphicon对top有1个像素的设置:<span style="color: #800000;">.glyphicon </span>{<span style="color: #ff0000;"> position</span>:<span style="color: #0000ff;"> relative</span>;<span style="color: #ff0000;"> top</span>:<span style="color: #0000ff;"> 1px</span>;<span style="color: #ff0000;"> display</span>:<span style="color: #0000ff;"> inline-block</span>;<span style="color: #ff0000;"> font-family</span>:<span style="color: #0000ff;"> 'Glyphicons Halflings'</span>;<span style="color: #ff0000;"> font-style</span>:<span style="color: #0000ff;"> normal</span>;<span style="color: #ff0000;"> font-weight</span>:<span style="color: #0000ff;"> normal</span>;<span style="color: #ff0000;"> line-height</span>:<span style="color: #0000ff;"> 1</span>;<span style="color: #ff0000;"> -webkit-font-smoothing</span>:<span style="color: #0000ff;"> antialiased</span>;<span style="color: #ff0000;"> -moz-osx-font-smoothing</span>:<span style="color: #0000ff;"> grayscale</span>; }Copy after login
二、导航条(navbar)
源码文件:
_navbar.scss
1、主要进行了内部区域的划分,如:head、其他区域;以及导航条位置的定位
2、折叠器实现(在4.0已移除),也就是navbar-collapse类,代替的是collapse,在按钮上面弹出隐藏层
2.1、Navbar-collapse:在大于breakpoint时,会强制显示(由于collapse默认是隐藏的)
3、内容支持nav、brand、form、toggler
4、Navbar-toggler(4.0移除):设定在屏幕小于breakpoint值时(768)显示,而在4.0则直接用collapse来展示此按钮,没有屏幕大小的限制,navbar-toggle的应用也要结合collapse使用
5、Navbar-static-top:只是增加了zIndex,去掉了圆角、边框宽度等内容。
6、Navbar-fixed-top/bottom:都是定位在上方、下方,有浮动影响
7、Navbar-brand:品牌,可以放网页名称、公司Logo等内容
8、Navbar-toggle:用于收缩的单击的图片,他会在小于breakpoint时显示,大于此值就隐藏(并且,toggle显示是右浮动,且作为相对定位元素):
9、Navbar-nav:原nav的基础进行了一些兼容设置,主是在breakpoint-max下的样式调整,以及在breakpointg下的样式调整,还是去掉默认的背景色,shadow等内容<span style="color: #800000;">.navbar-toggle </span>{<span style="color: #ff0000;"> position</span>:<span style="color: #0000ff;"> relative</span>;<span style="color: #ff0000;"> float</span>:<span style="color: #0000ff;"> right</span>;<span style="color: #ff0000;"> margin-right</span>:<span style="color: #0000ff;"> $navbar-padding-horizontal</span>;<span style="color: #ff0000;"> padding</span>:<span style="color: #0000ff;"> 9px 10px</span>;<span style="color: #ff0000;"> @include navbar-vertical-align(34px); background-color</span>:<span style="color: #0000ff;"> transparent</span>;<span style="color: #ff0000;"> background-image</span>:<span style="color: #0000ff;"> none</span>;<span style="color: #ff0000;"> // Reset unusual Firefox-on-Android default style; see https</span>:<span style="color: #0000ff;">//github.com/necolas/normalize.css/issues/214 border: 1px solid transparent</span>;<span style="color: #ff0000;"> border-radius</span>:<span style="color: #0000ff;"> $border-radius-base</span>;<span style="color: #ff0000;"> // We remove the `outline` here, but later compensate by attaching `</span>:<span style="color: #0000ff;">hover` // styles to `:focus`. &:focus { outline: 0</span>; }<span style="color: #800000;"> // Bars .icon-bar </span>{<span style="color: #ff0000;"> display</span>:<span style="color: #0000ff;"> block</span>;<span style="color: #ff0000;"> width</span>:<span style="color: #0000ff;"> 22px</span>;<span style="color: #ff0000;"> height</span>:<span style="color: #0000ff;"> 2px</span>;<span style="color: #ff0000;"> border-radius</span>:<span style="color: #0000ff;"> 1px</span>; }<span style="color: #800000;"> .icon-bar + .icon-bar </span>{<span style="color: #ff0000;"> margin-top</span>:<span style="color: #0000ff;"> 4px</span>; }<span style="color: #800000;"> @media (min-width: $grid-float-breakpoint) </span>{<span style="color: #ff0000;"> display</span>:<span style="color: #0000ff;"> none</span>; }<span style="color: #800000;"> }</span>Copy after login
10、Navbar-form:主要调整所有form都为行内元素
11、Navbar-text、navbar-btn:都在默认的基础上做了相就的兼容设置
12、Navbar提供了default、inverse两种主题,各主题下对其各自的部件都做了相应的样式兼容处理
13、导航条本身的样式不多,本身只提供了toggle、brand两个内容,主要提供了两种主题,以及将dropdown、collapse、form、nav四个部件的组合。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

To achieve the effect of scattering and enlarging the surrounding images after clicking on the image, many web designs need to achieve an interactive effect: click on a certain image to make the surrounding...

The Y-axis position adaptive algorithm for web annotation function This article will explore how to implement annotation functions similar to Word documents, especially how to deal with the interval between annotations...

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.
