1
1
1
1
1
1
1
1
1
1
1
1
4
4
4
4
8
6
6
12

The default grid system provided as part of Bootstrap is a 940px-wide, 12-column grid.

It also has four responsive variations for various devices and resolutions: phone, tablet portrait, table landscape and small desktops, and large widescreen desktops.

<div class="row">
  <div class="span4">...</div>
  <div class="span8">...</div>
</div>

As shown here, a basic layout can be created with two "columns," each spanning a number of the 12 foundational columns we defined as part of our grid system.


Offsetting columns

4
4 offset 4
3 offset 3
3 offset 3
8 offset 4
<div class="row">
  <div class="span4">...</div>
  <div class="span4 offset4">...</div>
</div>

Nesting columns

With the static (non-fluid) grid system in Bootstrap, nesting is easy. To nest your content, just add a new .row and set of .span* columns within an existing .span* column.

Example

Nested rows should include a set of columns that add up to the number of columns of it's parent. For example, two nested .span3 columns should be placed within a .span6.

Level 1 of column
Level 2
Level 2
<div class="row">
  <div class="span12">
    Level 1 of column
    <div class="row">
      <div class="span6">Level 2</div>
      <div class="span6">Level 2</div>
    </div>
  </div>
</div>

Fluid columns

1
1
1
1
1
1
1
1
1
1
1
1
4
4
4
4
8
6
6
12

Percents, not pixels

The fluid grid system uses percents for column widths instead of fixed pixels. It also has the same responsive variations as our fixed grid system, ensuring proper proportions for key screen resolutions and devices.

Fluid rows

Make any row fluid simply by changing .row to .row-fluid. The columns stay the exact same, making it super straightforward to flip between fixed and fluid layouts.

Markup

<div class="row-fluid">
  <div class="span4">...</div>
  <div class="span8">...</div>
</div>

Fluid nesting

Nesting with fluid grids is a bit different: the number of nested columns doesn't need to match the parent. Instead, your columns are reset at each level because each row takes up 100% of the parent column.

Fluid 12
Fluid 6
Fluid 6
<div class="row-fluid">
  <div class="span12">
    Level 1 of column
    <div class="row-fluid">
      <div class="span6">Level 2</div>
      <div class="span6">Level 2</div>
    </div>
  </div>
</div>
Variable Default value Description
@gridColumns 12 Number of columns
@gridColumnWidth 60px Width of each column
@gridGutterWidth 20px Negative space between columns
@siteWidth Computed sum of all columns and gutters Counts number of columns and gutters to set width of the .container-fixed() mixin

Variables in LESS

Built into Bootstrap are a handful of variables for customizing the default 940px grid system, documented above. All variables for the grid are stored in variables.less.

How to customize

Modifying the grid means changing the three @grid* variables and recompiling Bootstrap. Change the grid variables in variables.less and use one of the four ways documented to recompile. If you're adding more columns, be sure to add the CSS for those in grid.less.

Staying responsive

Customization of the grid only works at the default level, the 940px grid. To maintain the responsive aspects of Bootstrap, you'll also have to customize the grids in responsive.less.

Fixed layout

The default and simple 940px-wide, centered layout for just about any website or page provided by a single <div class="container">.

<body>
  <div class="container">
    ...
  </div>
</body>

Fluid layout

<div class="container-fluid"> gives flexible page structure, min- and max-widths, and a left-hand sidebar. It's great for apps and docs.

<div class="container-fluid">
  <div class="row-fluid">
    <div class="span2">
      <!--Sidebar content-->
    </div>
    <div class="span10">
      <!--Body content-->
    </div>
  </div>
</div>

Responsive devices

What they do

Media queries allow for custom CSS based on a number of conditions—ratios, widths, display type, etc—but usually focuses around min-width and max-width.

  • Modify the width of column in our grid
  • Stack elements instead of float wherever necessary
  • Resize headings and text to be more appropriate for devices

Use media queries responsibly and only as a start to your mobile audiences. For larger projects, do consider dedicated code bases and not layers of media queries.

Supported devices

Bootstrap supports a handful of media queries in a single file to help make your projects more appropriate on different devices and screen resolutions. Here's what's included:

Label Layout width Column width Gutter width
Smartphones 480px and below Fluid columns, no fixed widths
Smartphones to tablets 767px and below Fluid columns, no fixed widths
Portrait tablets 768px and above 42px 20px
Default 980px and up 60px 20px
Large display 1200px and up 70px 30px

Requires meta tag

To ensure devices display responsive pages properly, include the viewport meta tag.

<meta name="viewport" content="width=device-width, initial-scale=1.0">

Using the media queries

Bootstrap doesn't automatically include these media queries, but understanding and adding them is very easy and requires minimal setup. You have a few options for including the responsive features of Bootstrap:

  1. Use the compiled responsive version, bootstrap-responsive.css
  2. Add @import "responsive.less" and recompile Bootstrap
  3. Modify and recompile responsive.less as a separate file

Why not just include it? Truth be told, not everything needs to be responsive. Instead of encouraging developers to remove this feature, we figure it best to enable it.

// Landscape phones and down
@media (max-width: 480px) { ... }
// Landscape phone to portrait tablet
@media (max-width: 768px) { ... }
// Portrait tablet to landscape and desktop
@media (min-width: 768px) and (max-width: 980px) { ... }
// Large desktop
@media (min-width: 1200px) { .. }

Responsive utility classes

What are they

For faster mobile-friendly development, use these basic utility classes for showing and hidding content by device.

When to use

Use on a limited basis and avoid creating entirely different versions of the same site. Instead, use them to complement each device's presentation.

For example, you might show a <select> element for nav on mobile layouts, but not on tablets or desktops.

Support classes

Shown here is a table of the classes we support and their effect on a given media query layout (labeled by device). They can be found in responsive.less.

Class Phones 480px and below Tablets 767px and below Desktops 768px and above
.visible-phone Visible
.visible-tablet Visible
.visible-desktop Visible
.hidden-phone Visible Visible
.hidden-tablet Visible Visible
.hidden-desktop Visible Visible

Test case

Resize your browser or load on different devices to test the above clases.

Visible on...

  • Phone✔ Phone
  • Tablet✔ Tablet
  • Desktop✔ Desktop

Hidden on...

  • Phone✔ Phone
  • Tablet✔ Tablet
  • Desktop✔ Desktop
给宝宝豆腐的做法大全给宝宝做肉泥给宝宝提高抵抗力的药刚生完宝宝一周食谱刚出生宝宝如何呼吸给宝宝豆腐的做法大全刚生下来宝宝多大图片给宝宝提高抵抗力的药给宝宝打退烧针好吗给宝宝做洼丫鱼怎么做二岁宝宝有牙迹怎么办给宝宝豆腐的做法大全高潮对宝宝有影响吗?二岁宝宝有牙迹怎么办给宝宝提高抵抗力的药刚怀男宝宝有什么症状有哪些给宝宝调理脾胃推拿刚出生宝宝如何呼吸刚出生宝宝如何呼吸给2岁宝宝剪头发给宝宝戒夜奶给小宝宝取名给宝宝打退烧针好吗给宝宝做肉末粥的做法感冒了可以带宝宝吗给小宝宝听什么歌刚生完宝宝一周食谱给宝宝吃平果蒸了还有营养吗给2岁宝宝剪头发个高的宝宝走路晚己无法知晓这世界为何衰落,各种畸形怪物,食人恶魔随处出没。觉醒恶之系统的季尘将与另外四十人展开决斗,毁灭异或救赎世界走向由最后胜利者决定。 ※神魔大战之时※ ※神帝楚默却被卷入时空裂缝之中※ ※却穿越回蓝星故土大学时代※ ※皆看我征战魔窟,再封神帝,更进主宰!!!※ ※统宇宙之亿界,威人类之辉煌!!!※ 二十年前,他被一代道门隐脉奇人所救。二十年后,他遵守师父遗命下山踏入何家,阴差阳错之下成为何家的女婿,内心从抗拒到默默守护,皆因那一纸婚约而起!神魔复苏,天地动乱。天域?牢笼?于凡夫眼中的天人,或许才是最卑微的人族。我明征天人古族后裔,吞吐天地灵力,淬炼肉身宝藏,血宝无灵源,其刃当无敌。谁语凡夫堪蝼蚁?剑下神魔只称臣。兄弟几人修炼保护妹妹(姐姐)的小说 作者第一次写小说有不好的请谅解,也请大家多提提意见欢迎收看早间新闻...今天是2127年6月12日 自2122年以来全球降水量大幅下降,世界淡水储量急剧下降。 使得粮食产能严重不足,专家呼吁大家节约用水,减少非必要的淡水使用。珍惜粮食请勿浪费。 我国科研工作者经过三年的不懈努力,在今日凌晨终于研制成功z国首枚人工干预降雨火箭。火箭代号“甘露”。拥有【满级肉身】的苏叶,穿越异界,成为显魔宗疯魔院的杂役弟子! 被女魔头吊着打,获得天魔神掌。 被老魔头拿头撞,获得种魔大法。 被小魔头当沙包,获得霸王神斩。 …… 在疯魔院当杂役这些年。 有郁郁寡欢的师妹,来疯魔院供奉魔头,经苏叶指点,修成九世女帝! 有身世卑微的凡人,来疯魔院供奉魔头,经苏叶调教,成为天下共尊的魔皇! 有朝廷弃徒的皇子,来疯魔院供奉魔头,经苏叶点拨,成为横扫大陆的一代帝王! * 六十年后,魔道天榜揭示,排序魔道强者,苏叶独占鳌头! 榜单备注——神魔共主! …… 这是个陌生的世界,一切都是未知,一切又都很熟悉。在这里,谁也不能确定,下一秒是生是死,甚至死都不知道怎么死的。谁说凡人就不能修仙?谁说凡人就是鱼肉? 看我逆流而上,逆行伐仙!一个灵魂被一个小女孩救了下来,于是,从他出生的那一刻起,他就注定是她的使者。 他的结局早已注定,他会孤独的走完这条路。 道路之下,少年静静的坐在这里,他蓝色的眼眸不知是在注视何处。 他的身旁是一个金色头发的小女孩。 “我要将那些人一个不留的全部摧毁。” “我帮你。” “我要付出什么。” “全部。”
我的惊悚游戏实在太治愈了 权与断罪 太阳黑雨 生活随笔之一 大道天湮 易道归源 我在异世界躺平成神 仙鹤大人,爱上我 我即天命系统 哀须臾 渡劫飞升 都成圣主了,让我回地球? 重生王朝 三尺剑断天涯 重生之我的九十年代 我以一指,镇压诸天 扯淡:系统随机给我换身体 盘古地图 仙不可测 与我同在 给小宝宝听什么歌 刚怀男宝宝有什么症状有哪些 给宝宝喂辅食姿势 刚出生宝宝如何呼吸 给宝宝做肉泥 给宝宝吃平果蒸了还有营养吗 给宝宝喂辅食姿势 感受宝宝的心跳说说 宫寒月经不调贴暖宝宝 高潮对宝宝有影响吗? 刚出生宝宝喜欢抓脸 刚出生宝宝喜欢抓脸 给宝宝做肉末粥的做法 刚怀男宝宝有什么症状有哪些 给宝宝豆腐的做法大全 感冒了可以带宝宝吗 刚生过宝宝可以吃什么 给小宝宝听什么歌 给宝宝喂辅食吗 给宝宝提高抵抗力的药 给宝宝煮清汤面 给宝宝提高抵抗力的药 给宝宝喂辅食吗 给小宝宝取名 给宝宝做洼丫鱼怎么做 各个阶段锻炼宝宝 给小宝宝听什么歌 给宝宝喂辅食吗 给宝宝喂辅食吗 宫寒月经不调贴暖宝宝 刚出生宝宝如何呼吸 给宝宝煮清汤面 刚生完宝宝一周食谱 给宝宝豆腐的做法大全 给宝宝做肉末粥的做法 感冒了可以带宝宝吗 刚生完宝宝一周食谱 给宝宝喂辅食姿势 给宝宝做肉末粥的做法 刚满月宝宝着凉吐奶怎么办 感冒了可以带宝宝吗 感受宝宝的心跳说说 给2岁宝宝剪头发 刚生过宝宝可以吃什么 二岁宝宝有牙迹怎么办 给宝宝煮清汤面 刚出生宝宝喜欢抓脸 感冒了可以带宝宝吗 各个阶段锻炼宝宝 给宝宝调理脾胃推拿 亚星官网 亚星官网 亚星官网 亚星官网 亚星游戏官网 数的灵魂感 新中医时代 医婿高手 位面之灵 梦中的我不同凡响 AG真人 欧博官网 亚星游戏官网 AG真人 百家乐官网 给宝宝喂辅食吗 给宝宝戒夜奶 高潮对宝宝有影响吗? 给宝宝提高抵抗力的药 刚出生宝宝如何呼吸 个高的宝宝走路晚 给宝宝调理脾胃推拿 个高的宝宝走路晚 给宝宝做肉末粥的做法 刚生下来宝宝多大图片 刚生过宝宝可以吃什么 给宝宝吃平果蒸了还有营养吗 给宝宝做洼丫鱼怎么做 二岁宝宝有牙迹怎么办 给宝宝戒夜奶 给宝宝按摩手指的手法 刚满月宝宝着凉吐奶怎么办 给宝宝豆腐的做法大全 给小宝宝听什么歌 感受宝宝的心跳说说 给宝宝调理脾胃推拿 给宝宝提高抵抗力的药 给宝宝吃平果蒸了还有营养吗 给小宝宝听什么歌 二岁宝宝有牙迹怎么办 给宝宝吃平果蒸了还有营养吗 给2岁宝宝剪头发 刚出生宝宝如何呼吸 给2岁宝宝剪头发 刚出生宝宝喜欢抓脸