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
宝宝爬比赛怎么比6个月宝宝能吃多少香瓜宝宝脾胃不还会干呕吗?宝宝前脑门位置发红宝宝全麻补牙有影响吗宝宝爬比赛怎么比宝宝起来一直流鼻涕怎么办宝宝脾胃不还会干呕吗?宝宝气虚的原因宝宝验血有病毒感染宝宝眼睛鼓个包图宝宝爬比赛怎么比宝宝频繁换环境好不好宝宝眼睛鼓个包图宝宝脾胃不还会干呕吗?宝宝眼皮有小红疙瘩是怎么回事儿宝宝肉末炖蛋怎么做好吃宝宝全麻补牙有影响吗宝宝全麻补牙有影响吗宝宝能随便吃打虫药吗宝宝潜能开发的书宝宝缺锌应该补什么宝宝气虚的原因宝宝三周还不会用筷子宝宝荨麻疹照片6个月宝宝能吃几颗樱桃宝宝前脑门位置发红宝宝三伏贴有效果宝宝能随便吃打虫药吗宝宝七个月喝水容易呛还有精灵么? 抱歉,你来晚了,精灵已分发完毕。 啊?能不能走个后门,给我个不听话的... 没等说完,管理员就“砰”的关上窗口。 西树:?? 联盟就这服务态度?我要去投诉! 随便,你投诉联盟,关我们火箭队啥事儿。 【无金手指,非正经精灵文。】这个世界需要充启?? 即使有很多的美好。 但它一片死寂, 谁?到底是谁? 明明只是神的一个错误, 什么别有用心的人利用了它, 为什么谁要创造这样的世界, 它明明毫无意义, 或许吧??南海东郊白鹭岛,山野成氏人家,有一祖传宝玉,竟然是外星人到地球寻觅多年的绝密宝藏。 董事长苏菲菲非他不嫁,华夏国公主不做公主也要嫁他,澳墨克星球女国王万里迢迢寻夫...... 而他,却只想与心爱的女人,看看山,种种菜,不问世事,百年相好! “穿越绑定说书人系统,一百年后我才知道,我居然就是我话本故事里的那个主角!” “敢情老子一直都在讲自己未来的命运!” 那些说过的情节,全都变成真的了…… 但是如果再给程夏一次机会,他……还会这么选择。 我们的故事,始于禹州的临安茶馆,终于苍茫天地之间。 新作者发书求支持! 有评论必爆更! 一位满目苍桑的老人,眯着眼倚坐在藤椅上,知吖吖的响着。藤椅旁,大黄趴在地上睡的正香。老爷子看起来就像是已经入土为安,躺倒在这片土地上一般。 一道光线照在老人身上,老人缓缓张开双眼。一个穿着黑衣的少女,站立于光束之下,看着这个年过花甲的老人,她的脸色有些悲戚,但却带着坚毅,眼中有着无尽的痛苦,看向这个老人的眼神也充满了复杂的感情。少女的右手紧握,似乎是用了极大的力气握住手中的长剑。 少女看向老人,嘴角露出一丝微笑。 “你来了”老人看着面前的少女,没有丝毫的惊讶,似乎早有预料,淡淡的说道。男主张小华是个高材生,在机缘巧合下穿越到了一个从未听过的古代异世界……我天生能看到奇怪的东西,爸妈担心我出事便让我拜师隐藏。可就在一次熟人的胁迫式“邀请”,师傅用两片龙鳞再次揭开了我的秘密,自此,我便走上了一条未曾想过的路??王珂,一个普通的社畜,末世来临之际意外获得超能力,从此在末世混的风生水起,称霸一方。2656年———一个科技的时代 在这一年,人类文明已高度发达,逐渐转移家园,在宇宙之中寻找居住地。 而在这样的时代,人类却已忘记了孕育他的地球。高尖端人才们却抛弃了她,只留下一些“低级人类”们在这“低级星球”上自生自灭。人们也不得不将地球重新分洲,分别是:东洲、西洲、南州、北洲。其中,西洲与东洲因为没有留下任何技术导制文化崩溃,退回到2025年左右的经济。南州和北洲因为技术保存较好而存在于2200年左右的经济。 但是令那些资本家没想到的是,在这落后族群:地球上,会因为一次浩劫而改变他们的看法...... 通道异变,乱世将至。江辰通过秘术一步先步步先。在这群雄并起的世代,且看我江辰一剑斩妖,一剑除魔,一剑登天。
苍天龙猫 诡异世界小管家 全能制作人 燕武纪 焦土幸存者 洛洛历险记:无敌超速风 在修仙世界努力御兽这件事 万界逆旅 星核之小兵狂想曲 战风新纪元:央隆比亚 大唐苟富贵 野火春菲 玄幻之我的开挂人生 人间游乐园 网游:我能无限复制 中唐明帝 我在仙界有个爹 末世之每日一签算吉凶 精灵世纪:王者归来 太阳领主上岗记 6个月宝宝能吃几颗樱桃 宝宝眼皮有小红疙瘩是怎么回事儿 宝宝乳头结痂掉了 宝宝全麻补牙有影响吗 6个月宝宝能吃多少香瓜 宝宝三伏贴有效果 宝宝乳头结痂掉了 宝宝屁股被烫感染图片 6个月宝宝说话没反应 宝宝频繁换环境好不好 宝宝起水痘385正常吗 宝宝起水痘385正常吗 宝宝三周还不会用筷子 宝宝眼皮有小红疙瘩是怎么回事儿 宝宝爬比赛怎么比 宝宝荨麻疹照片 宝宝散光要戴眼镜吗 6个月宝宝能吃几颗樱桃 宝宝三伏天晚上吃什么水果 宝宝脾胃不还会干呕吗? 宝宝眼睛有黄浓状态 宝宝脾胃不还会干呕吗? 宝宝三伏天晚上吃什么水果 宝宝缺锌应该补什么 宝宝验血有病毒感染 宝宝每个月都吃美林 6个月宝宝能吃几颗樱桃 宝宝三伏天晚上吃什么水果 宝宝三伏天晚上吃什么水果 6个月宝宝说话没反应 宝宝全麻补牙有影响吗 宝宝眼睛有黄浓状态 宝宝前脑门位置发红 宝宝爬比赛怎么比 宝宝三周还不会用筷子 宝宝荨麻疹照片 宝宝前脑门位置发红 宝宝乳头结痂掉了 宝宝三周还不会用筷子 宝宝七个月大喝牛骨汤 宝宝荨麻疹照片 宝宝屁股被烫感染图片 宝宝能随便吃打虫药吗 宝宝散光要戴眼镜吗 宝宝眼睛鼓个包图 宝宝眼睛有黄浓状态 宝宝起水痘385正常吗 宝宝荨麻疹照片 宝宝每个月都吃美林 宝宝肉末炖蛋怎么做好吃 亚星官网 亚星游戏官网 亚星游戏官网 亚星官网 亚星官网 墨羽笙箫传 你,想要封神吗 高三的我回到小学 怪物猎人有单 大玄印 亚星游戏官网 万利游戏官网 万利官网 亚星游戏官网 葡京官网 宝宝起水痘385正常吗 宝宝乳头结痂掉了 宝宝潜能开发的书 宝宝眼睛鼓个包图 宝宝验血有病毒感染 宝宝眼皮有小红疙瘩是怎么回事儿 6个月宝宝能吃几颗樱桃 宝宝气虚的原因 6个月宝宝能吃几颗樱桃 宝宝七个月大喝牛骨汤 宝宝前脑门位置发红 6个月宝宝能吃几颗樱桃 宝宝肉末炖蛋怎么做好吃 宝宝前脑门位置发红 宝宝缺锌应该补什么 宝宝缺锌应该补什么 宝宝能随便吃打虫药吗 宝宝三周还不会用筷子 宝宝眼皮有小红疙瘩是怎么回事儿 宝宝起水痘385正常吗 宝宝潜能开发的书 宝宝气虚的原因 宝宝频繁换环境好不好 宝宝爬比赛怎么比 宝宝荨麻疹照片 宝宝频繁换环境好不好 宝宝起来一直流鼻涕怎么办 宝宝频繁换环境好不好 宝宝三周还不会用筷子 宝宝七个月喝水容易呛