Atualizado
Atualizado
Our Bootstrap grid is a powerful mobile-first flexbox grid which helps you build layouts of all shapes and sizes thanks to a twelve column system, five default responsive tiers, Sass variables and mixins, and dozens of predefined classes.
Bootstrap grid system uses a series of containers, rows, and columns to layout and aligns content. Itβs built with and is fully responsive. Below is an example and an in-depth look at how the grid comes together.
New to or unfamiliar with flexbox? for background, terminology, guidelines, and code snippets.
One of three columnsOne of three columnsOne of three columnsCopy
The above example creates three equal-width columns on small, medium, large, and extra large devices using our predefined grid classes. Those columns are centered in the page with the parent .container
.
See how aspects of the Bootstrap grid system work across multiple devices with a handy table.
Utilize breakpoint-specific column classes for easy column sizing without an explicit numbered class like .col-sm-6
.
For example, here are two grid layouts that apply to every device and viewport, from xs
to xl
. Add any number of unit-less classes for each breakpoint you need and every column will be the same width.
1 of 22 of 21 of 32 of 33 of 3Copy
ColumnColumnColumnColumnCopy
Auto-layout for flexbox grid columns also means you can set the width of one column and have the sibling columns automatically resize around it. You may use predefined grid classes (as shown below), grid mixins, or inline widths. Note that the other columns will resize no matter the width of the center column.
1 of 32 of 3 (wider)3 of 31 of 32 of 3 (wider)3 of 3Copy
Use col-{breakpoint}-auto
classes to size columns based on the natural width of their content.
1 of 3Variable width content3 of 31 of 3Variable width content3 of 3Copy
Create equal-width columns that span multiple rows by inserting a .w-100
where you want the columns to break to a new line. Make the breaks responsive by mixing the .w-100
with some responsive display utilities.
colcolcolcolCopy
Bootstrapβs grid includes five tiers of predefined classes for building complex responsive layouts. Customize the size of your columns on extra small, small, medium, large, or extra large devices however you see fit.
For grids that are the same from the smallest of devices to the largest, use the .col
and .col-*
classes. Specify a numbered class when you need a particularly sized column; otherwise, feel free to stick to .col
.
colcolcolcolcol-8col-4Copy
Using a single set of .col-sm-*
classes, you can create a basic grid system that starts out stacked and becomes horizontal at the small breakpoint (sm
).
col-sm-8col-sm-4col-smcol-smcol-smCopy
Donβt want your columns to simply stack in some grid tiers? Use a combination of different classes for each tier as needed. See the example below for a better idea of how it all works.
.col-12 .col-md-8.col-6 .col-md-4.col-6 .col-md-4.col-6 .col-md-4.col-6 .col-md-4.col-6.col-6Copy
For faster mobile-friendly and responsive development, Bootstrap includes dozens of utility classes for showing, hiding, aligning, and spacing content.
Containers are the most basic layout element in Bootstrap and are required when using our default grid system. Containers are used to contain, pad, and (sometimes) center the content within them. While containers can be nested, most layouts do not require a nested container.
Bootstrap comes with three different containers:
.container
, which sets a max-width at each responsive breakpoint
.container-fluid
, which is width: 100% at all breakpoints
.container-{breakpoint}
, which is width: 100% until the specified breakpoint
While Bootstrap uses em
s or rem
s for defining most sizes, px
s are used for grid breakpoints and container widths. This is because the viewport width is in pixels and does not change with the .
Equal-width columns can be broken into multiple lines, but there was a that prevented this from working without an explicit flex-basis
or border
. There are workarounds for older browser versions, but they shouldnβt be necessary if youβre up-to-date.
Extra Small <576px
Small β₯576px
Medium β₯768px
Large β₯992px
Extra Large β₯1200px
XXL β₯1400px
Max container width
None (auto)
540px
720px
960px
1140px
1320px
Class prefix
.col-
.col-sm-
.col-md-
.col-lg-
.col-xl-
.col-xxl-
# of columns
12
Gutter width
30px (15px on each side of a column)
Nestable
Yes
Column ordering
Yes