Use our powerful mobile-first flexbox grid to 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. Show
How it worksBootstrap’s grid system uses a series of containers, rows, and columns to layout and align content. It’s built with flexbox 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.
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 9.Breaking it down, here’s how it works:
Be aware of the limitations and bugs around flexbox, like the . Grid optionsWhile Bootstrap uses 7s or 8s for defining most sizes, 9s are used for grid breakpoints and container widths. This is because the viewport width is in pixels and does not change with the .See how aspects of the Bootstrap grid system work across multiple devices with a handy table. <576pxSmall ≥576pxMedium ≥768pxLarge ≥992pxExtra large ≥1200pxMax container widthNone (auto)540px720px960px1140pxClass prefix 0 1 2 3 4# of columns12Gutter width30px (15px on each side of a column)NestableYesColumn orderingYesAuto-layout columnsUtilize breakpoint-specific column classes for easy column sizing without an explicit numbered class like 5.Equal-widthFor example, here are two grid layouts that apply to every device and viewport, from 5 to 7. Add any number of unit-less classes for each breakpoint you need and every column will be the same width.
Equal-width columns can be broken into multiple lines, but there was a that prevented this from working without an explicit 8 or 9. There are workarounds for older browser versions, but they shouldn’t be necessary if you’re up-to-date.
Setting one column widthAuto-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.
Variable width contentUse 0 classes to size columns based on the natural width of their content.
Equal-width multi-rowCreate equal-width columns that span multiple rows by inserting a 1 where you want the columns to break to a new line. Make the breaks responsive by mixing the 1 with some responsive display utilities.
Responsive classesBootstrap’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. All breakpointsFor grids that are the same from the smallest of devices to the largest, use the 3 and 4 classes. Specify a numbered class when you need a particularly sized column; otherwise, feel free to stick to 3.
Stacked to horizontalUsing a single set of 6 classes, you can create a basic grid system that starts out stacked before becoming horizontal with at the small breakpoint ( 7).
Mix and matchDon’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.
AlignmentUse flexbox alignment utilities to vertically and horizontally align columns. Vertical alignment
0Horizontal alignment 1No guttersThe gutters between columns in our predefined grid classes can be removed with 2. This removes the negative 0s from 3 and the horizontal 3 from all immediate children columns.Here’s the source code for creating these styles. Note that column overrides are scoped to only the first children columns and are targeted via attribute selector. While this generates a more specific selector, column padding can still be further customized with spacing utilities. Need an edge-to-edge design? Drop the parent 9 or 1. 2In practice, here’s how it looks. Note you can continue to use this with all other predefined grid classes (including column widths, responsive tiers, reorders, and more). .col-12 .col-sm-6 .col-md-8 3Column wrappingIf more than 12 columns are placed within a single row, each group of extra columns will, as one unit, wrap onto a new line. .col-4 .col-6 4Column breaksBreaking columns to a new line in flexbox requires a small hack: add an element with 2 wherever you want to wrap your columns to a new line. Normally this is accomplished with multiple 3s, but not every implementation method can account for this. 5You may also apply this break at specific breakpoints with our responsive display utilities. 6ReorderingOrder classesUse 6 classes for controlling the visual order of your content. These classes are responsive, so you can set the 7 by breakpoint (e.g., 8). Includes support for 9 through 0 across all five grid tiers. 7There are also responsive 1 and 2 classes that change the 7 of an element by applying 4 and 5 ( 6), respectively. These classes can also be intermixed with the numbered 7 classes as needed. 8Offsetting columnsYou can offset grid columns in two ways: our responsive 8 grid classes and our margin utilities. Grid classes are sized to match columns while margins are more useful for quick layouts where the width of the offset is variable.Offset classesMove columns to the right using 9 classes. These classes increase the left margin of a column by 0 columns. For example, 1 moves 2 over four columns. 9In addition to column clearing at responsive breakpoints, you may need to reset offsets. See this in action in the grid example. .col-sm-5 .offset-sm-2 .col-md-6 .offset-md-0 .col-sm-6 .col-md-5 .col-lg-6 .col-sm-6 .col-md-5 .offset-md-2 .col-lg-6 .offset-lg-0 0Margin utilitiesWith the move to flexbox in v4, you can use margin utilities like 3 to force sibling columns away from one another. 1NestingTo nest your content with the default grid, add a new 3 and set of 6 columns within an existing 6 column. Nested rows should include a set of columns that add up to 12 or fewer (it is not required that you use all 12 available columns).Level 1: .col-sm-9 Level 2: .col-8 .col-sm-6 Level 2: .col-4 .col-sm-6 2Sass mixinsWhen using Bootstrap’s source Sass files, you have the option of using Sass variables and mixins to create custom, semantic, and responsive page layouts. Our predefined grid classes use these same variables and mixins to provide a whole suite of ready-to-use classes for fast responsive layouts. VariablesVariables and maps determine the number of columns, the gutter width, and the media query point at which to begin floating columns. We use these to generate the predefined grid classes documented above, as well as for the custom mixins listed below. 3MixinsMixins are used in conjunction with the grid variables to generate semantic CSS for individual grid columns. 4Example usageYou can modify the variables to your own custom values, or just use the mixins with their default values. Here’s an example of using the default settings to create a two-column layout with a gap between. 5 6Customizing the gridUsing our built-in grid Sass variables and maps, it’s possible to completely customize the predefined grid classes. Change the number of tiers, the media query dimensions, and the container widths—then recompile. Columns and guttersThe number of grid columns can be modified via Sass variables. 7 is used to generate the widths (in percent) of each individual column while 8 allows breakpoint-specific widths that are divided evenly across 9 and 00 for the column gutters. 7Grid tiersMoving beyond the columns themselves, you may also customize the number of grid tiers. If you wanted just four grid tiers, you’d update the 01 and 02 to something like this: 8When making any changes to the Sass variables or maps, you’ll need to save your changes and recompile. Doing so will output a brand new set of predefined grid classes for column widths, offsets, and ordering. Responsive visibility utilities will also be updated to use the custom breakpoints. Make sure to set grid values in 9 (not 8, 7, or 06).
Ada berapakah jumlah grid system pada bootstrap?Grid system pada bootstrap memiliki 5 class yang memiliki fungsi masing – masing, antara lain : .col – : (digunakan untuk device yang sangat kecil dengan ukuran lebar layar kurang dari 576 pixel)
Apa itu class Row?Class row berfungsi untuk mengubah sifat dari div di dalamnya yang semula akan ditampilkan secara block, akan dapat ditampilkan secara inline. Maka dari itu div di dalamnya dapat dipaparkan secara horizontal. Class col berfungsi untuk mengubah div tersebut menjadi responsif terhadap lebar viewport.
Apa itu Container bootstrap?Container bisa kita anggap sebagai wadah yang menampung semua element grid sistem atau element lain nya dari bootstrap. Class containers adalah class terluar dari sebuah elemen konten, dimana class ini akan mengatur lebar konten sesuai dengan class yang digunakan.
Apakah kamu tahu sistem yang merupakan pengaturan lebar untuk masing masing komponen pada bootstrap disebut?Grid system adalah sistem pengaturan lebar untuk masing-masing komponen yang ingin kita buat. pengaturan ini bertujuan untuk mengatur ke-responsive-an website yang kita buar. Jadi kita bisa mengaturnya sesuai yang kita inginkan dengan sangat mudah.
|