├── README.md ├── TOC.md ├── Untitled.md ├── components ├── alerts.md ├── badges.md ├── breadcrumbs.md ├── button-dropdowns.md ├── button-groups.md ├── dropdowns.md ├── glyphicons.md ├── input-groups.md ├── jumbotron.md ├── labels.md ├── list-group.md ├── media-object.md ├── navbar.md ├── navs.md ├── page-header.md ├── pagination.md ├── panels.md ├── progress-bars.md ├── responsive-embed.md ├── thumbnails.md └── wells.md ├── css ├── buttons.md ├── code.md ├── forms.md ├── grid-system.md ├── helper-classes.md ├── images.md ├── overview.md ├── responsive-utilities.md ├── tables.md ├── typography.md ├── using-less.md └── using-sass.md ├── customize ├── download.md ├── import.md ├── jquery-plugins.md ├── less-components .md └── less-variables.md ├── getting-started ├── accessibility.md ├── basic-template.md ├── browser-and-device-support.md ├── community.md ├── compiling-css-and-javascript.md ├── disabling-responsiveness.md ├── download.md ├── examples.md ├── license-faqs.md ├── migrating-from-v2.x-to-v3.x.md ├── third-party-support.md ├── tools.md ├── translations.md └── what-included.md ├── images └── bootstrap.jpg └── javascript ├── affix.md ├── alert.md ├── button.md ├── carousel.md ├── collapse.md ├── dropdowns.md ├── modal.md ├── overview.md ├── popovers.md ├── scrollspy.md ├── tab.md ├── tooltips.md └── transitions.md /README.md: -------------------------------------------------------------------------------- 1 | # Bootstrap 官方文档中文版 2 | 3 | Bootstrap 官方文档(英文原版): 4 | 5 | - [Getting started](http://getbootstrap.com/getting-started/) 6 | - [CSS](http://getbootstrap.com/css/) 7 | - [Components](http://getbootstrap.com/components/) 8 | - [JavaScript](http://getbootstrap.com/javascript/) 9 | - [customize](http://getbootstrap.com/customize/) 10 | 11 | ## 目的 12 | 13 | 翻译 Bootstrap 官方文档,目录见文件「[TOC.md](TOC.md)」 14 | 15 | ## 极客学院 Wiki 协作规范 16 | 17 | https://github.com/jikexueyuanwiki/guide 18 | 19 | ## 如何添加图片 20 | 21 | 前提:官网上的所有图片都已经下载下来放入「images」文件夹,图片的文件名没做任何修改。 22 | 23 | 1. 请引用「images」文件夹中的图片,不要直接引用官方上的图片链接; 24 | 2. 引用「images」文件夹时,请使用相对文件路径。 25 | -------------------------------------------------------------------------------- /TOC.md: -------------------------------------------------------------------------------- 1 | - 起步-Getting started 2 | - [下载 - Download](getting-started/download.md) 3 | - [包含的内容 - What included](getting-started/what-included.md) 4 | - [编译 CSS 和 JavaScript 文件 - Compiling CSS and JavaScript](getting-started/compiling-css-and-javascript.md) 5 | - [基本模板 - Basic template](getting-started/basic-template.md) 6 | - [实例精选 - Examples](getting-started/examples.md) 7 | - [工具 - Tools](getting-started/tools.md) 8 | - [社区 - Community](getting-started/community.md) 9 | - [禁止响应式布局 - Disabling responsiveness](getting-started/disabling-responsiveness.md) 10 | - [从 2.x 版本升级到 3.0 版本 - Migrating from v2.x to v3.x](getting-started/migrating-from-v2.x-to-v3.x.md) 11 | - [对浏览器和设备的支持情况 - Browser and device support](getting-started/browser-and-device-support.md) 12 | - [对第三方组件的支持 - Third party support](getting-started/third-party-support.md) 13 | - [可访问性 - Accessibility](getting-started/accessibility.md) 14 | - [许可证 FAQ - License FAQs](getting-started/license-faqs.md) 15 | - [文档翻译 - Translations](getting-started/translations.md) 16 | - CSS 17 | - [概览 - Overview](css/overview.md) 18 | - [栅格系统 - Grid system](css/grid-system.md) 19 | - [排版 - Typography](css/typography.md) 20 | - [代码 - Code](css/code.md) 21 | - [表格 - Tables](css/tables.md) 22 | - [表单 - Forms](css/forms.md) 23 | - [按钮 - Buttons](css/buttons.md) 24 | - [图片 - Images](css/Images.md) 25 | - [辅助类 - Helper classes](css/helper-classes.md) 26 | - [响应式工具 - Responsive utilities](css/responsive-utilities.md) 27 | - [使用 Less - Using Less](css/using-less.md) 28 | - [使用 Sass - Using Sass](css/using-sass.md) 29 | - 组件-Components 30 | - [Glyphicons 字体图标 - Glyphicons](components/glyphicons.md) 31 | - [下拉菜单 - Dropdowns](components/dropdowns.md) 32 | - [按钮组 - Button groups](components/button-groups.md) 33 | - [按钮式下拉菜单 - Button dropdowns](components/button-dropdowns.md) 34 | - [输入框组 - Input groups](components/input-groups.md) 35 | - [导航 - Navs](components/navs.md) 36 | - [导航条 - Navbar](components/navbar.md) 37 | - [路径导航 - Breadcrumbs](components/breadcrumbs.md) 38 | - [分页 - Pagination](components/pagination.md) 39 | - [标签 - Labels](components/labels.md) 40 | - [徽章 - Badges](components/badges.md) 41 | - [巨幕 - Jumbotron](components/jumbotron.md) 42 | - [页头 - Page header](components/page-header.md) 43 | - [缩略图 - Thumbnails](components/thumbnails.md) 44 | - [警告框 - Alerts](components/alerts.md) 45 | - [进度条 - Progress bars](components/progress-bars.md) 46 | - [媒体对象 - Media object](components/media-object.md) 47 | - [列表组 - List group](components/list-group.md) 48 | - [面板 - Panels](components/panels.md) 49 | - [具有响应式特性的嵌入内容 - Responsive embed](components/responsive-embed.md) 50 | - [Well - Wells](components/wells.md) 51 | - JavaScript 52 | - [概览 - Overview](javascript/overview.md) 53 | - [过渡效果 - Transitions](javascript/transitions.md) 54 | - [模态框 - Modal](javascript/modal.md) 55 | - [下拉菜单 - Dropdowns](javascript/dropdowns.md) 56 | - [滚动监听 - Scrollspy](javascript/scrollspy.md) 57 | - [标签页 - Tab](javascript/tab.md) 58 | - [工具提示 - Tooltips](javascript/tooltips.md) 59 | - [弹出框 - Popovers](javascript/popovers.md) 60 | - [警告框 - Alert](javascript/alert.md) 61 | - [按钮 - Button](javascript/button.md) 62 | - [Collapse - Collapse](javascript/collapse.md) 63 | - [Carousel - Carousel](javascript/carousel.md) 64 | - [Affix - Affix](javascript/affix.md) 65 | - 定制-Customize 66 | - [入口 - Import](customize/import.md) 67 | - [较小的组件 - Less components](customize/less-components.md) 68 | - [jQuery插件 - jQuery plugins](customize/jquery-plugins.md) 69 | - [较小的变量 - Less variables](customize/less-variables.md) 70 | - [下载 - Download](customize/download.md) 71 | 72 | -------------------------------------------------------------------------------- /Untitled.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/Untitled.md -------------------------------------------------------------------------------- /components/alerts.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/components/alerts.md -------------------------------------------------------------------------------- /components/badges.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/components/badges.md -------------------------------------------------------------------------------- /components/breadcrumbs.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/components/breadcrumbs.md -------------------------------------------------------------------------------- /components/button-dropdowns.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/components/button-dropdowns.md -------------------------------------------------------------------------------- /components/button-groups.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/components/button-groups.md -------------------------------------------------------------------------------- /components/dropdowns.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/components/dropdowns.md -------------------------------------------------------------------------------- /components/glyphicons.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/components/glyphicons.md -------------------------------------------------------------------------------- /components/input-groups.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/components/input-groups.md -------------------------------------------------------------------------------- /components/jumbotron.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/components/jumbotron.md -------------------------------------------------------------------------------- /components/labels.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/components/labels.md -------------------------------------------------------------------------------- /components/list-group.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/components/list-group.md -------------------------------------------------------------------------------- /components/media-object.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/components/media-object.md -------------------------------------------------------------------------------- /components/navbar.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/components/navbar.md -------------------------------------------------------------------------------- /components/navs.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/components/navs.md -------------------------------------------------------------------------------- /components/page-header.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/components/page-header.md -------------------------------------------------------------------------------- /components/pagination.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/components/pagination.md -------------------------------------------------------------------------------- /components/panels.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/components/panels.md -------------------------------------------------------------------------------- /components/progress-bars.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/components/progress-bars.md -------------------------------------------------------------------------------- /components/responsive-embed.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/components/responsive-embed.md -------------------------------------------------------------------------------- /components/thumbnails.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/components/thumbnails.md -------------------------------------------------------------------------------- /components/wells.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/components/wells.md -------------------------------------------------------------------------------- /css/buttons.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/css/buttons.md -------------------------------------------------------------------------------- /css/code.md: -------------------------------------------------------------------------------- 1 | ## 代码 2 | 3 | ### 内联代码 4 | 通过 ``标签包裹内联样式的代码片段。 5 | 6 | 7 | 8 | 9 | ``` 10 | For example, <section> should be wrapped as inline. 11 | ``` 12 | ###用户输入 13 | 通过 `` 标签标记用户通过键盘输入的内容。= 14 | 15 | 16 | 17 | ``` 18 | To switch directories, type cd followed by the name of the directory.
19 | To edit settings, press ctrl + , 20 | ``` 21 | ###代码块 22 | 多行代码可以使用 `
` 标签。为了正确的展示代码,注意将尖括号做转义处理。
23 | 
24 | 
25 | 
26 | ```
27 |     
<p>Sample text here...</p>
28 | ``` 29 | 还可以使用 `.pre-scrollable` 类,其作用是设置 max-height 为 350px ,并在垂直方向展示滚动条。 30 | 31 | 变量 32 | 通过 `` 标签标记变量。 33 | 34 | 35 | 36 | 37 | ``` 38 | y = mx + b 39 | ``` 40 | 程序输出 41 | 通过 标签来标记程序输出的内容。 42 | 43 | 44 | 45 | 46 | ``` 47 | This text is meant to be treated as sample output from a computer program. 48 | ``` 49 | -------------------------------------------------------------------------------- /css/forms.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/css/forms.md -------------------------------------------------------------------------------- /css/grid-system.md: -------------------------------------------------------------------------------- 1 | # 栅格系统 2 | 3 | Bootstrap 提供了一套响应式、移动设备优先的流式栅格系统,随着屏幕或视口(viewport)尺寸的增加,系统会自动分为最多12列。它包含了易于使用的预定义类,还有强大的mixin 用于生成更具语义的布局。 4 | 5 | ## 简介 6 | 栅格系统用于通过一系列的行(row)与列(column)的组合来创建页面布局,你的内容就可以放入这些创建好的布局中。下面就介绍一下 Bootstrap 栅格系统的工作原理: 7 | 8 | “行(row)”必须包含在 `.container` (固定宽度)或 `.container-fluid` (100% 宽度)中,以便为其赋予合适的排列(aligment)和内补(padding)。 9 | 通过“行(row)”在水平方向创建一组“列(column)”。 10 | 你的内容应当放置于“列(column)”内,并且,只有“列(column)”可以作为行(row)”的直接子元素。 11 | 类似 `.row` 和 `.col-xs-4` 这种预定义的类,可以用来快速创建栅格布局。Bootstrap 源码中定义的 mixin 也可以用来创建语义化的布局。 12 | 通过为“列(column)”设置 `padding` 属性,从而创建列与列之间的间隔(gutter)。通过为 `.row` 元素设置负值 `margin` 从而抵消掉为 `.container` 元素设置的 `padding`,也就间接为“行(row)”所包含的“列(column)”抵消掉了`padding`。 13 | The negative margin is why the examples below are outdented. It's so that content within grid columns is lined up with non-grid content. 14 | Grid columns are created by specifying the number of twelve available columns you wish to span. For example, three equal columns would use three `.col-xs-4`. 15 | 如果一“行(row)”中包含了的“列(column)”大于 12,多余的“列(column)”所在的元素将被作为一个整体另起一行排列。 16 | Grid classes apply to devices with screen widths greater than or equal to the breakpoint sizes, and override grid classes targeted at smaller devices. Therefore, e.g. applying any `.col-md-*` class to an element will not only affect its styling on medium devices but also on large devices if a `.col-lg-*` class is not present. 17 | 通过研究后面的实例,可以将这些原理应用到你的代码中。 18 | 19 | ## 媒体查询 20 | 在栅格系统中,我们在 Less 文件中使用以下媒体查询(media query)来创建关键的分界点阈值。 21 | 22 | ``` 23 | /* 超小屏幕(手机,小于 768px) */ 24 | /* 没有任何媒体查询相关的代码,因为这在 Bootstrap 中是默认的(还记得 Bootstrap 是移动设备优先的吗?) */ 25 | 26 | /* 小屏幕(平板,大于等于 768px) */ 27 | @media (min-width: @screen-sm-min) { ... } 28 | 29 | /* 中等屏幕(桌面显示器,大于等于 992px) */ 30 | @media (min-width: @screen-md-min) { ... } 31 | 32 | /* 大屏幕(大桌面显示器,大于等于 1200px) */ 33 | @media (min-width: @screen-lg-min) { ... } 34 | ``` 35 | 36 | 我们偶尔也会在媒体查询代码中包含 `max-width` 从而将 CSS 的影响限制在更小范围的屏幕大小之内。 37 | 38 | ``` 39 | @media (max-width: @screen-xs-max) { ... } 40 | @media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) { ... } 41 | @media (min-width: @screen-md-min) and (max-width: @screen-md-max) { ... } 42 | @media (min-width: @screen-lg-min) { ... } 43 | ``` 44 | ## 栅格参数 45 | 通过下表可以详细查看 Bootstrap 的栅格系统是如何在多种屏幕设备上工作的。 46 | 47 | 超小屏幕 手机 (<768px) 小屏幕 平板 (≥768px) 中等屏幕 桌面显示器 (≥992px) 大屏幕 大桌面显示器 (≥1200px) 48 | 栅格系统行为 总是水平排列 开始是堆叠在一起的,当大于这些阈值时将变为水平排列C 49 | `.container` 最大宽度 None (自动) 750px 970px 1170px 50 | 类前缀 `.col-xs-` `.col-sm-` `.col-md-` `.col-lg-` 51 | 列(column)数 12 52 | 最大列(column)宽 自动 ~62px ~81px ~97px 53 | 槽(gutter)宽 30px (每列左右均有 15px) 54 | 可嵌套 是 55 | 偏移(Offsets) 是 56 | 列排序 是 57 | ## 实例:从堆叠到水平排列 58 | 使用单一的一组 `.col-md-*` 栅格类,就可以创建一个基本的栅格系统,在手机和平板设备上一开始是堆叠在一起的(超小屏幕到小屏幕这一范围),在桌面(中等)屏幕设备上变为水平排列。所有“列(column)必须放在 ” `.row` 内。 59 | 60 | .col-md-1.col-md-1.col-md-1.col-md-1.col-md-1.col-md-1.col-md-1.col-md-1.col-md-1.col-md-1.col-md-1.col-md-1 61 | .col-md-8.col-md-4 62 | .col-md-4.col-md-4.col-md-4 63 | .col-md-6.col-md-6 64 | 65 | ``` 66 |
67 |
.col-md-1
68 |
.col-md-1
69 |
.col-md-1
70 |
.col-md-1
71 |
.col-md-1
72 |
.col-md-1
73 |
.col-md-1
74 |
.col-md-1
75 |
.col-md-1
76 |
.col-md-1
77 |
.col-md-1
78 |
.col-md-1
79 |
80 |
81 |
.col-md-8
82 |
.col-md-4
83 |
84 |
85 |
.col-md-4
86 |
.col-md-4
87 |
.col-md-4
88 |
89 |
90 |
.col-md-6
91 |
.col-md-6
92 |
93 | ``` 94 | ## 实例:流式布局容器 95 | 将最外面的布局元素 `.container` 修改为 `.container-fluid`,就可以将固定宽度的栅格布局转换为 100% 宽度的布局。 96 | 97 | ``` 98 |
99 |
100 | ... 101 |
102 |
103 | ``` 104 | ## 实例:移动设备和桌面屏幕 105 | 是否不希望在小屏幕设备上所有列都堆叠在一起?那就使用针对超小屏幕和中等屏幕设备所定义的类吧,即 `.col-xs-*` 和 `.col-md-*`。请看下面的实例,研究一下这些是如何工作的。 106 | 107 | .col-xs-12 .col-md-8.col-xs-6 .col-md-4 108 | .col-xs-6 .col-md-4.col-xs-6 .col-md-4.col-xs-6 .col-md-4 109 | .col-xs-6.col-xs-6 110 | 111 | ``` 112 | 113 |
114 |
.col-xs-12 .col-md-8
115 |
.col-xs-6 .col-md-4
116 |
117 | 118 | 119 |
120 |
.col-xs-6 .col-md-4
121 |
.col-xs-6 .col-md-4
122 |
.col-xs-6 .col-md-4
123 |
124 | 125 | 126 |
127 |
.col-xs-6
128 |
.col-xs-6
129 |
130 | ``` 131 | 132 | ## 实例:手机、平板、桌面 133 | 在上面案例的基础上,通过使用针对平板设备的 `.col-sm-*` 类,我们来创建更加动态和强大的布局吧。 134 | 135 | .col-xs-12 .col-sm-6 .col-md-8.col-xs-6 .col-md-4 136 | .col-xs-6 .col-sm-4.col-xs-6 .col-sm-4.col-xs-6 .col-sm-4 137 | 138 | ``` 139 |
140 |
.col-xs-12 .col-sm-6 .col-md-8
141 |
.col-xs-6 .col-md-4
142 |
143 |
144 |
.col-xs-6 .col-sm-4
145 |
.col-xs-6 .col-sm-4
146 | 147 |
148 |
.col-xs-6 .col-sm-4
149 |
150 | ``` 151 | 152 | ## 实例:多余的列(column)将另起一行排列 153 | 如果在一个 `.row` 内包含的列(column)大于12个,包含多余列(column)的元素将作为一个整体单元被另起一行排列。 154 | 155 | .col-xs-9.col-xs-4 156 | Since 9 + 4 = 13 > 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit..col-xs-6 157 | Subsequent columns continue along the new line. 158 | 159 | ``` 160 |
161 |
.col-xs-9
162 |
.col-xs-4
Since 9 + 4 = 13 > 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.
163 |
.col-xs-6
Subsequent columns continue along the new line.
164 |
165 | ``` 166 | 167 | ## Responsive column resets 168 | With the four tiers of grids available you're bound to run into issues where, at certain breakpoints, your columns don't clear quite right as one is taller than the other. To fix that, use a combination of a `.clearfix` and our responsive utility classes. 169 | 170 | .col-xs-6 .col-sm-3 171 | Resize your viewport or check it out on your phone for an example. .col-xs-6 .col-sm-3.col-xs-6 .col-sm-3.col-xs-6 .col-sm-3 172 | 173 | ``` 174 |
175 |
.col-xs-6 .col-sm-3
176 |
.col-xs-6 .col-sm-3
177 | 178 | 179 |
180 | 181 |
.col-xs-6 .col-sm-3
182 |
.col-xs-6 .col-sm-3
183 |
184 | ``` 185 | 186 | In addition to column clearing at responsive breakpoints, you may need to **reset offsets, pushes, or pulls**. See this in action in the grid example. 187 | 188 | ``` 189 |
190 |
.col-sm-5 .col-md-6
191 |
.col-sm-5 .col-sm-offset-2 .col-md-6 .col-md-offset-0
192 |
193 | 194 |
195 |
.col-sm-6 .col-md-5 .col-lg-6
196 |
.col-sm-6 .col-md-5 .col-md-offset-2 .col-lg-6 .col-lg-offset-0
197 |
198 | ``` 199 | 200 | ## 列偏移 201 | 使用 `.col-md-offset-* `类可以将列向右侧偏移。这些类实际是通过使用 `* `选择器为当前元素增加了左侧的边距(margin)。例如,`.col-md-offset-4 `类将 `.col-md-4` 元素向右侧偏移了4个列(column)的宽度。 202 | 203 | .col-md-4.col-md-4 .col-md-offset-4 204 | .col-md-3 .col-md-offset-3.col-md-3 .col-md-offset-3 205 | .col-md-6 .col-md-offset-3 206 | 207 | ``` 208 |
209 |
.col-md-4
210 |
.col-md-4 .col-md-offset-4
211 |
212 |
213 |
.col-md-3 .col-md-offset-3
214 |
.col-md-3 .col-md-offset-3
215 |
216 |
217 |
.col-md-6 .col-md-offset-3
218 |
219 | ``` 220 | 221 | ## 嵌套列 222 | 为了使用内置的栅格系统将内容再次嵌套,可以通过添加一个新的 `.row` 元素和一系列 `.col-sm-*` 元素到已经存在的 `.col-sm-*` 元素内。被嵌套的行(row)所包含的列(column)的个数不能超过12(其实,没有要求你必须占满12列)。 223 | 224 | Level 1: .col-sm-9 225 | Level 2: .col-xs-8 .col-sm-6 Level 2: .col-xs-4 .col-sm-6 226 | 227 | ``` 228 |
229 |
230 | Level 1: .col-sm-9 231 |
232 |
233 | Level 2: .col-xs-8 .col-sm-6 234 |
235 |
236 | Level 2: .col-xs-4 .col-sm-6 237 |
238 |
239 |
240 |
241 | ``` 242 | 243 | ## 列排序 244 | 通过使用 `.col-md-push-*`和 `.col-md-pull-*` 类就可以很容易的改变列(column)的顺序。 245 | 246 | .col-md-9 .col-md-push-3.col-md-3 .col-md-pull-9 247 | 248 | ``` 249 |
250 |
.col-md-9 .col-md-push-3
251 |
.col-md-3 .col-md-pull-9
252 |
253 | ``` 254 | ## Less mixin 和变量 255 | 除了用于快速布局的预定义栅格类,Bootstrap 还包含了一组 Less 变量和 mixin 用于帮你生成简单、语义化的布局。 256 | 257 | ### 变量 258 | 259 | 通过变量来定义列数、槽(gutter)宽、媒体查询阈值(用于确定合适让列浮动)。我们使用这些变量生成预定义的栅格类,如上所示,还有如下所示的定制 mixin。 260 | 261 | ``` 262 | @grid-columns: 12; 263 | @grid-gutter-width: 30px; 264 | @grid-float-breakpoint: 768px; 265 | ``` 266 | 267 | ### mixin 268 | 269 | 270 | mixin 用来和栅格变量一同使用,为每个列(column)生成语义化的 CSS 代码。 271 | 272 | ``` 273 | // Creates a wrapper for a series of columns 274 | .make-row(@gutter: @grid-gutter-width) { 275 | // Then clear the floated columns 276 | .clearfix(); 277 | 278 | @media (min-width: @screen-sm-min) { 279 | margin-left: (@gutter / -2); 280 | margin-right: (@gutter / -2); 281 | } 282 | 283 | // Negative margin nested rows out to align the content of columns 284 | .row { 285 | margin-left: (@gutter / -2); 286 | margin-right: (@gutter / -2); 287 | } 288 | } 289 | 290 | // Generate the extra small columns 291 | .make-xs-column(@columns; @gutter: @grid-gutter-width) { 292 | position: relative; 293 | // Prevent columns from collapsing when empty 294 | min-height: 1px; 295 | // Inner gutter via padding 296 | padding-left: (@gutter / 2); 297 | padding-right: (@gutter / 2); 298 | 299 | // Calculate width based on number of columns available 300 | @media (min-width: @grid-float-breakpoint) { 301 | float: left; 302 | width: percentage((@columns / @grid-columns)); 303 | } 304 | } 305 | 306 | // Generate the small columns 307 | .make-sm-column(@columns; @gutter: @grid-gutter-width) { 308 | position: relative; 309 | // Prevent columns from collapsing when empty 310 | min-height: 1px; 311 | // Inner gutter via padding 312 | padding-left: (@gutter / 2); 313 | padding-right: (@gutter / 2); 314 | 315 | // Calculate width based on number of columns available 316 | @media (min-width: @screen-sm-min) { 317 | float: left; 318 | width: percentage((@columns / @grid-columns)); 319 | } 320 | } 321 | 322 | // Generate the small column offsets 323 | .make-sm-column-offset(@columns) { 324 | @media (min-width: @screen-sm-min) { 325 | margin-left: percentage((@columns / @grid-columns)); 326 | } 327 | } 328 | .make-sm-column-push(@columns) { 329 | @media (min-width: @screen-sm-min) { 330 | left: percentage((@columns / @grid-columns)); 331 | } 332 | } 333 | .make-sm-column-pull(@columns) { 334 | @media (min-width: @screen-sm-min) { 335 | right: percentage((@columns / @grid-columns)); 336 | } 337 | } 338 | 339 | // Generate the medium columns 340 | .make-md-column(@columns; @gutter: @grid-gutter-width) { 341 | position: relative; 342 | // Prevent columns from collapsing when empty 343 | min-height: 1px; 344 | // Inner gutter via padding 345 | padding-left: (@gutter / 2); 346 | padding-right: (@gutter / 2); 347 | 348 | // Calculate width based on number of columns available 349 | @media (min-width: @screen-md-min) { 350 | float: left; 351 | width: percentage((@columns / @grid-columns)); 352 | } 353 | } 354 | 355 | // Generate the medium column offsets 356 | .make-md-column-offset(@columns) { 357 | @media (min-width: @screen-md-min) { 358 | margin-left: percentage((@columns / @grid-columns)); 359 | } 360 | } 361 | .make-md-column-push(@columns) { 362 | @media (min-width: @screen-md-min) { 363 | left: percentage((@columns / @grid-columns)); 364 | } 365 | } 366 | .make-md-column-pull(@columns) { 367 | @media (min-width: @screen-md-min) { 368 | right: percentage((@columns / @grid-columns)); 369 | } 370 | } 371 | 372 | // Generate the large columns 373 | .make-lg-column(@columns; @gutter: @grid-gutter-width) { 374 | position: relative; 375 | // Prevent columns from collapsing when empty 376 | min-height: 1px; 377 | // Inner gutter via padding 378 | padding-left: (@gutter / 2); 379 | padding-right: (@gutter / 2); 380 | 381 | // Calculate width based on number of columns available 382 | @media (min-width: @screen-lg-min) { 383 | float: left; 384 | width: percentage((@columns / @grid-columns)); 385 | } 386 | } 387 | 388 | // Generate the large column offsets 389 | .make-lg-column-offset(@columns) { 390 | @media (min-width: @screen-lg-min) { 391 | margin-left: percentage((@columns / @grid-columns)); 392 | } 393 | } 394 | .make-lg-column-push(@columns) { 395 | @media (min-width: @screen-lg-min) { 396 | left: percentage((@columns / @grid-columns)); 397 | } 398 | } 399 | .make-lg-column-pull(@columns) { 400 | @media (min-width: @screen-lg-min) { 401 | right: percentage((@columns / @grid-columns)); 402 | } 403 | } 404 | ``` 405 | 406 | ## 实例展示 407 | 408 | 你可以重新修改这些变量的值,或者用默认值调用这些 mixin。下面就是一个利用默认设置生成两列布局(列之间有间隔)的案例。 409 | 410 | ``` 411 | .wrapper { 412 | .make-row(); 413 | } 414 | .content-main { 415 | .make-lg-column(8); 416 | } 417 | .content-secondary { 418 | .make-lg-column(3); 419 | .make-lg-column-offset(1); 420 | } 421 | ``` 422 | 423 | ``` 424 |
425 |
...
426 |
...
427 |
428 | ``` 429 | -------------------------------------------------------------------------------- /css/helper-classes.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/css/helper-classes.md -------------------------------------------------------------------------------- /css/images.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/css/images.md -------------------------------------------------------------------------------- /css/overview.md: -------------------------------------------------------------------------------- 1 | # 概览 2 | 3 | 深入了解 Bootstrap 底层结构的关键部分,包括我们让 web 开发变得更好、更快、更强壮的最佳实践。 4 | 5 | ## HTML5 文档类型 6 | Bootstrap 使用到的某些 HTML 元素和 CSS 属性需要将页面设置为 HTML5 文档类型。在你项目中的每个页面都要参照下面的格式进行设置。 7 | 8 | ``` 9 | 10 | 11 | ... 12 | 13 | ``` 14 | ## 移动设备优先 15 | 在 Bootstrap 2 中,我们对框架中的某些关键部分增加了对移动设备友好的样式。而在 Bootstrap 3 中,我们重写了整个框架,使其一开始就是对移动设备友好的。这次不是简单的增加一些可选的针对移动设备的样式,而是直接融合进了框架的内核中。也就是说,**Bootstrap 是移动设备优先的**。针对移动设备的样式融合进了框架的每个角落,而不是增加一个额外的文件。 16 | 17 | 为了确保适当的绘制和触屏缩放,需要在 `` 之中**添加 viewport 元数据标签**。 18 | 19 | ``` 20 | 21 | ``` 22 | 在移动设备浏览器上,通过为视口(viewport)设置 meta 属性为 `user-scalable=no` 可以禁用其缩放(zooming)功能。这样禁用缩放功能后,用户只能滚动屏幕,就能让你的网站看上去更像原生应用的感觉。注意,这种方式我们并不推荐所有网站使用,还是要看你自己的情况而定! 23 | 24 | ``` 25 | 26 | ``` 27 | ## 排版与链接 28 | Bootstrap 排版、链接样式设置了基本的全局样式。分别是: 29 | 30 | 为 `body` 元素设置 `background-color: #fff`; 31 | 使用 `@font-family-base`、`@font-size-base` 和 `@line-height-base` a变量作为排版的基本参数 32 | 为所有链接设置了基本颜色 `@link-color` ,并且当链接处于 `:hover` 状态时才添加下划线 33 | 这些样式都能在 `scaffolding.less` 文件中找到对应的源码。 34 | 35 | ## Normalize.css 36 | 为了增强跨浏览器表现的一致性,我们使用了 Normalize.css,这是由 Nicolas Gallagher 和 Jonathan Neal 维护的一个CSS 重置样式库。 37 | 38 | 布局容器 39 | Bootstrap 需要为页面内容和栅格系统包裹一个 `.container` 容器。我们提供了两个作此用处的类。注意,由于 `padding` 等属性的原因,这两种 容器类不能互相嵌套。 40 | 41 | `.container` 类用于固定宽度并支持响应式布局的容器。 42 | 43 | ``` 44 |
45 | ... 46 |
47 | ``` 48 | `.container-fluid` 类用于 100% 宽度,占据全部视口(viewport)的容器。 49 | 50 | ``` 51 |
52 | ... 53 |
54 | ``` 55 | -------------------------------------------------------------------------------- /css/responsive-utilities.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/css/responsive-utilities.md -------------------------------------------------------------------------------- /css/tables.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jikexueyuanwiki/bootstrap/bc3a67d90d6c1cc74fc82a980a8bf205f7885206/css/tables.md -------------------------------------------------------------------------------- /css/typography.md: -------------------------------------------------------------------------------- 1 | # 排版 2 | 3 | ## 标题 4 | HTML 中的所有标题标签,`

` 到 `

` 均可使用。另外,还提供了 `.h1` 到 `.h6` 类,为的是给内联(inline)属性的文本赋予标题的样式。 5 | 6 | 7 | 8 | ``` 9 |

h1. Bootstrap heading

10 |

h2. Bootstrap heading

11 |

h3. Bootstrap heading

12 |

h4. Bootstrap heading

13 |
h5. Bootstrap heading
14 |
h6. Bootstrap heading
15 | ``` 16 | 在标题内还可以包含 `` 标签或赋予 `.small` 类的元素,可以用来标记副标题。 17 | 18 | 19 | 20 | ``` 21 |

h1. Bootstrap heading Secondary text

22 |

h2. Bootstrap heading Secondary text

23 |

h3. Bootstrap heading Secondary text

24 |

h4. Bootstrap heading Secondary text

25 |
h5. Bootstrap heading Secondary text
26 |
h6. Bootstrap heading Secondary text
27 | ``` 28 | ## 页面主体 29 | Bootstrap 将全局 `font-size` 设置为 14px,`line-height` 设置为 1.428。这些属性直接赋予 `` 元素和所有段落元素。另外,`

` (段落)元素还被设置了等于 1/2 行高(即 10px)的底部外边距(margin)。 30 | 31 | 32 | 33 | ``` 34 |

...

35 | ``` 36 | 37 | ###中心内容 38 | 通过添加 `.lead` 类可以让段落突出显示。 39 | 40 | 41 | 42 | 43 | ``` 44 |

...

45 | ``` 46 | ###使用 Less 工具构建 47 | **variables.less** 文件中定义的两个 Less 变量决定了排版尺寸:`@font-size-base` 和 @line-height-base。第一个变量定义了全局 font-size 基准,第二个变量是 line-height 基准。我们使用这些变量和一些简单的公式计算出其它所有页面元素的 margin、 padding 和 line-height。自定义这些变量即可改变 Bootstrap 的默认样式。 48 | 49 | ##内联文本元素 50 | ###Marked text 51 | For highlighting a run of text due to its relevance in another context, use the `` tag. 52 | 53 | 54 | 55 | 56 | ``` 57 | You can use the mark tag to highlight text. 58 | ``` 59 | ###被删除的文本 60 | 对于被删除的文本使用 `` 标签。 61 | 62 | 63 | 64 | 65 | ``` 66 | This line of text is meant to be treated as deleted text. 67 | ``` 68 | ###无用文本 69 | 对于没用的文本使用 `` 标签。 70 | 71 | 72 | 73 | 74 | ``` 75 | This line of text is meant to be treated as no longer accurate. 76 | ``` 77 | ###插入文本 78 | 额外插入的文本使用 `` 标签。 79 | 80 | 81 | 82 | 83 | ``` 84 | This line of text is meant to be treated as an addition to the document. 85 | ``` 86 | ###带下划线的文本 87 | 为文本添加下划线,使用 `` 标签。 88 | 89 | 90 | 91 | 92 | ``` 93 | This line of text will render as underlined 94 | ``` 95 | 利用 HTML 自带的表示强调意味的标签来为文本增添少量样式。 96 | 97 | ###小号文本 98 | 对于不需要强调的inline或block类型的文本,使用 `` 标签包裹,其内的文本将被设置为父容器字体大小的 85%。标题元素中嵌套的 `` 元素被设置不同的 `font-size` 。 99 | 100 | 你还可以为行内元素赋予 `.small` 类以代替任何 `` 元素。 101 | 102 | 103 | 104 | 105 | ``` 106 | This line of text is meant to be treated as fine print. 107 | ``` 108 | ###着重 109 | 通过增加 font-weight 值强调一段文本。 110 | 111 | 112 | 113 | ``` 114 | rendered as bold text 115 | ``` 116 | ###斜体 117 | 用斜体强调一段文本。 118 | 119 | 120 | 121 | ``` 122 | rendered as italicized text 123 | ``` 124 | 125 | **Alternate elements** 126 | 127 | 在 HTML5 中可以放心使用 `` 和 `` 标签。`` 用于高亮单词或短语,不带有任何着重的意味;而 `` 标签主要用于发言、技术词汇等。 128 | ##对齐 129 | 通过文本对齐类,可以简单方便的将文字重新对齐。 130 | 131 | 132 | 133 | 134 | ``` 135 |

Left aligned text.

136 |

Center aligned text.

137 |

Right aligned text.

138 |

Justified text.

139 |

No wrap text.

140 | ``` 141 | ##改变大小写 142 | 通过这几个类可以改变文本的大小写。 143 | 144 | 145 | 146 | 147 | ``` 148 |

Lowercased text.

149 |

Uppercased text.

150 |

Capitalized text.

151 | ``` 152 | ##缩略语 153 | 当鼠标悬停在缩写和缩写词上时就会显示完整内容,Bootstrap 实现了对 HTML 的 `` 元素的增强样式。缩略语元素带有 `title` 属性,外观表现为带有较浅的虚线框,鼠标移至上面时会变成带有“问号”的指针。如想看完整的内容可把鼠标悬停在缩略语上(对使用辅助技术的用户也可见), 但需要包含 title 属性。 154 | 155 | ###基本缩略语 156 | 157 | 158 | 159 | 160 | ``` 161 | attr 162 | ``` 163 | ###首字母缩略语 164 | 为缩略语添加 `.initialism` 类,可以让 font-size 变得稍微小些。 165 | 166 | 167 | 168 | 169 | ``` 170 | HTML 171 | ``` 172 | ##地址 173 | 让联系信息以最接近日常使用的格式呈现。在每行结尾添加 `
` 可以保留需要的样式。 174 | 175 | 176 | 177 | 178 | ``` 179 |
180 | Twitter, Inc.
181 | 795 Folsom Ave, Suite 600
182 | San Francisco, CA 94107
183 | P: (123) 456-7890 184 |
185 | 186 |
187 | Full Name
188 | first.last@example.com 189 |
190 | ``` 191 | ##引用 192 | 在你的文档中引用其他来源的内容。 193 | 194 | ###默认样式的引用 195 | 将任何 HTML 元素包裹在 `
` 中即可表现为引用样式。对于直接引用,我们建议用 `

` 标签。 196 | 197 | 198 | 199 | 200 | ``` 201 |

202 |

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.

203 |
204 | ``` 205 | ###Blockquote options 206 | Style and content changes for simple variations on a standard `
`. 207 | 208 | ####Naming a source 209 | 210 | Add a `