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
美团网营销内容南京需要做网站的公司杭州 网站建站杭州做网站营销型网站优化深圳品牌网站推广天津网站优化公司信息安全 管理需求 技术需求网站备案时间网络安全需要注意哪些汉中做网站公安网络安全培训课程达内培训 网络营销网络营销课程设计网络营销学习微黄式营销网络营销入门远程营销策划网络安全产品 选型一般公司为网络安全设置怎样的防火墙设计方案seo优化网站建设公司网络安全管理办公室网络安全云管理平台移动营销优缺点网络信息安全备案公众号营销策划狼客网络营销国家注册信息安全员cism信息安全2000亿网络信息安全硬件设备网络安全法 讲解手机版网站设计风格由于我特别喜欢鸣人小樱这一对,所以我想试着实现它,同时我希望火影不会出现血统论,这次的鸣人不会开挂。未来不仅只有星空大海,还有神话永生!自小能与神秘盖亚生命互换灵魂的东希,如何在这个世界走上巅峰! 绝世天帝重生为家族赘婿,受尽他人白眼,却觉醒宝物镇天神符。 修武道,踏万界,镇天地万物,成众生之主。 “这世间天才千千万,唯我林枫一人能镇压!”二十年前,龙国江城,第一世家裘家被一夜灭门,本以为一切都遮掩的没有一丝破绽,但是却没算到裘家最小的孩子活了下来,并且成为一代战神,他从来没忘却过家族的仇恨,只不过作为军人的操守,不会无故杀人,除了他的仇敌之外,但一切并不如他所想,他不杀人,不代表不会有人会因为他的追查而被灭口,就比如刚刚别灭的江城汪家,只是撕开了当年裘家灭门惨案的一角而已高考又一次失败,却意外进入了神秘学院。从此踏入了宿命早已注定的道途。 犯我中华者,虽远必诛! 有我在!尔等休想猖狂!在17岁的年纪里,即将开始人生的另一个起点………………听老人讲民间故事奇闻杂谈惊悚传说还有最终结果末世危机突然降临,世间人性在末世的摧残之下统统暴露出最真实的一面,这凄惨人间是否需要毁灭,又是否能获新生?而又是谁来做出这一切?吞天三千界,帝陨傲世间,做妖三千载,为她弃凡尘元育大陆,地主家庭的他刚出生父母便遭到杀害,后被医师教导长大,6岁时送往修仙宗门,身负蕴魔体的他是隐藏自身魔气,一步步成为大陆高手,抵抗天外的邪灵。
绿盟网络安全审计 网络信息安全硬件设备 健康起源秉承怎样的营销理念. 全响应网站制作 营销学术语 企业网络合作营销案例 东南亚 网络安全 信息网络安全员培训 东莞政府信息安全 网络安全信息安全实验室 h5营销策略 网站备案时间 网络安全 比赛 网络营销效果评价指标体系 什么网站流量高 外贸营销平台有哪些 改网站标题 杭州专业做网站的公司 网站页面优化 潍坊市网站制作 网络营销期刊有哪些 搜索营销公司怎么样 武汉网站程序 常见网络安全的威胁和攻击有哪些 江苏省信息安全测评中心 汉中做网站 网络营销学习 我国信息安全部门 一、一个甜品网站建设目标 网络间接营销 企业网站更新什么内容 公安网络安全培训课程 信息安全管理培训 网络安全云管理平台 移动营销优缺点 网站建设价格标准信息 网络安全售后服务 网站建设干货 我国信息安全部门 企业网站更新什么内容