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
社会热点素材作文什么等于幸福作文升国旗的作文300字省考作文光写意义食品安全隐患作文英文社会热点素材作文适当的追星英语作文升国旗的作文300字生命!生命!作文300字使用手机的利弊 英文作文什么是安全作文600字升国旗的作文300字失败也是一种体验 作文什么给了我启示作文600字作文开头生命的故事作文.350字使用手机的利弊 英文作文生活中的高兴事作文400字湿地芦苇的作文湿地芦苇的作文石榴花开了作文什么什么的启示作文600字作文湿地芦苇的作文生命!生命!作文300字什么的旅游作文1000字食品安全隐患作文英文什么安全作文600字失败的味道作文350字什么的旅游作文1000字石榴花开了作文失败也是一种体验 作文我是一个男神,超级无敌! 我正在上大学,因为天生的神神基因,加上后天的锻炼,浑身上下,便拥有万般的神力。 一个人的力量,可以对付无数的平常之人。 加上,我长相柔美,貌似美丽的女孩子一般。 许多女孩子甫一见到我,就会深深地爱上我。 无论我走到那里,都会遇到情痴痴的女孩子。 女孩子们疯一般,痴痴地纠缠住我,骚扰我,令我烦不胜烦。 我是男神,超级无敌,却无法摆脱女孩子们热烈的纠缠。 哎!男神魅力,超级无敌呀!是做上天的宠儿,自出生那一刻起就受苍天庇佑?还是夺天造化,逆天而行,踏出一条无法回头的道路? “究竟何为巅峰?” 九百年前,玄荒帝尊第一次对这片天地产生了怀疑。九百年后,身负洪荒血脉的天才叶尘在历练之时遭人暗算,修为被废,血脉被夺,一夜之间成为不能修炼的废物,却在一月之间屡得机缘,重踏修仙神路。 “与天斗,当真是其乐无穷……” 且看废柴少年叶尘踏上逆天之路,一步步拨开笼罩在仙武大陆上的那片迷雾…… 陈寻怎么也想不到,自己机缘巧合参加的一次相亲经历,竟然就此翻转了他的整个人生。尘寰外,碧海中,桃花之间桃花岛。秋风起,海波兴,几度潮来听玉箫。且看东邪黄药师传人,如何纵横都市。满天神佛朝我跪拜,天下美女唯我独揽!已完本,放心阅读。万年之前,天元和天魂两大神王飞升。 万年之后,黑渊降临,两大神王陨落重生。 重生后,两大神王再次登顶,冲击更高的境界! 区区神王不能满足我的要求!我要登顶神帝!我要成为这万界之主! 巨变来临,新一轮的主境强者即将出世,一路逆袭,任我修为再低,这天也不是我的对手! 都市社畜少年意外身穿蓝星,竟发现此地灵气复苏?什么?少年看了看手机里的修仙挂机游戏,歪嘴一笑。 描写人与人之间,微妙的关系叶天本想桃花源里隐居过着咸鱼般的生活,却意外被美女网红直播。 你以为他是医神?活人无数? 他代表月亮消灭你! 你以为他是影帝? 他赌石赢到手软! 神医妙手,黄金圣瞳,绝世杀神,校花终结者…… 这个主播的马甲有亿点点多!阳衡意外穿越异界,觉醒亿万增幅修炼系统 系统:“少年,你想变强吗?来来来,只需首充六块下品灵石,你就是本系统尊贵的VP1会员。” 阳衡:“会员有啥用。” 系统:“能够解锁亿万倍增幅修炼,还能额外赠送系统大礼包。’ 叮,恭喜你充值成功,成为尊贵的VIP1用户,你将获得十倍增幅修炼,获得天赋神通固若金汤。 叮,恭喜你充值成功,成为尊贵的VP1用户,你将获得百倍增幅修炼,获得天赋神通六星火神之赞。 莫非应和图灿分离后换上了“双重人格”,三年后图灿回来第一件事就是找他,没想到在小姨的精神病院找到。同时她也没想到,她的男友居然是她的同类,她好不容易(意外)治好了莫非,却发现莫非居然不是人,但这并不妨碍他们在一起,莫非:“把我弄成这个样子,可要好好负责。”图灿一边流着口水一边说:“好好好。”
神樱祝祷 虚无仙神 当神话出现 遥远的天空之镜 碧澜沧海传 我在异世也当狗? 网文大学笔记 转职成为魔剑士的那段日子 生命裁决者 天间录 原力觉醒,我在城市打怪物 我在游戏世界无敌 异世界精苏系统:起家 白云历险记 森林之子 王座上的木偶 重生:神级御兽师 夜雨香 无愧 蓝星:三维的末路 时尚的奶奶 作文 三年级学生故事作文 生活中的高兴事作文400字 食品安全隐患作文英文 时尚的奶奶 作文 什么的教育作文800字 生活中的高兴事作文400字 什么的教育作文 什么安全作文600字 收获半命题作文初中 生命!生命!作文300字 生活中的高兴事作文300 什么的青春路作文指导 三年级学生故事作文 社会热点素材作文 食品安全隐患作文英文 食品安全隐患作文英语 什么安全作文600字 手机对人的坏处英语作文 升国旗的作文300字 三年级学生故事作文 生命的故事作文.350字 什么等于幸福作文 什么给了我启示作文600字作文开头 使用手机的利弊 英文作文 什么的青春路作文指导 什么安全作文600字 什么等于幸福作文 手机对人的坏处英语作文 什么安全作文600字 食品安全隐患作文英文 什么是安全作文600字 省考作文光写意义 社会热点素材作文 什么的旅游作文1000字 食品安全隐患作文英文 省考作文光写意义 生活中的高兴事作文400字 什么的青春路作文指导 生命的故事作文.350字 失败的味道作文350字 收获半命题作文初中 什么是安全作文1000字 食品安全隐患作文英语 什么给了我启示作文600字作文开头 三年级学生故事作文 生活中的高兴事作文300 失败的味道作文350字 什么的青春路作文指导 适当的追星英语作文 亚星官网 亚星官网 亚星官网 亚星官网 亚星游戏官网 九牧 文艺巨星奶爸 冠绝当世 人在迪迦我老婆是居间惠 开局我就不是人了?! 葡京官网 快连下载 欧博官网 葡京官网 皇冠登3出租 什么安全作文600字 省考作文光写意义 什么的青春路作文指导 什么的教育作文800字 什么是安全作文600字 什么的旅游作文1000字 什么是安全作文1000字 什么给了我启示作文600字作文开头 社会热点素材作文 生命!生命!作文300字 生命的故事作文.350字 生命!生命!作文300字 失败也是一种体验 作文 什么什么的启示作文600字作文 失败的味道作文350字 时尚的奶奶 作文 食品安全隐患作文英文 失败也是一种体验 作文 什么给了我启示作文600字作文开头 食品安全隐患作文英文 生活中的高兴事作文300 湿地芦苇的作文 三年级学生故事作文 食品安全隐患作文英语 使用手机的利弊 英文作文 什么是安全作文1000字 收获半命题作文初中 什么是安全作文1000字 时尚的奶奶 作文 社会热点素材作文