Grid System:
Basics
AppStrap includes the powerful mobile-first 12 column flexbox-powered grid system from Bootstrap plus a few extras.
The grid system allows you to alyout content on your pages and alter the layout based on the screenwidth of the page/browser.
Mobile-first
Mobile-first means that you consider your default layout to be mobile/small screens and then you progressively enhance it up as the screenwidth increases. This is the approach Bootstrap adopted since version 3 although some media queries do go against this where it makes sense.
Flexbox
Since Bootstrap 4 Alplha 6 Bootstrap has Flexbox support by default which makes use of the powerful CSS flexbile box layout module opening up a whole new world of grid power!
Internet Explorer 9 (and below) does not support Flexbox at all but fortunately AppStrap provides built in fallbacks so your AppStrap based sites will look great in Internet Explorer 9 anyway.
You can also choose to "opt out" of using Flexbox with AppStrap by simply adding the following line of code after all the other CSS files are included within the head tags: View code example
This will override the Bootstrap Flexbox elements and core AppStrap elements so they use display block & floats instead, magic!
Grid Structure
Basic struction of a grid is: .container|.container-fluid > .row > .col|col-BREAKPOINT-(1-12)|col-(1-12)
Containers
.container|.container-fluid are wrappers that center the content on the page, .container has fixed pixel widths which vary with the screensize and .container-fluid stretches full width of the screen.
Rows
.row applies the Flexbox properties which should be applied to the .col|col-BREAKPOINT-(1-12)|col-(1-12) elements within it. By default it sets them to show as "rows" aligned side by side.
Columns
.col|col-BREAKPOINT-(1-12)|col-(1-12) elements determine the percentage width to give a column within the grid and at which "breakpoint" that width should be set from.
Grid columns without a set width will automatically layout with equal widths. For example, four instances of .col-sm will each automatically be 25% wide for small breakpoints.
Column classes indicate the number of columns you want to use out of the possible 12 per row. So, if you want three equal-width columns, you can use .col-sm-4. 12 is considered "full width".
If more than 12 columns are placed within a single row, each group of extra columns will, as one unit, wrap onto a new line.
Breakpoints
Breakpoints are the point at which the screenwidth increases or decreases from one recognised point to the next. In AppStrap there are 5 breakpoints you can work with: all breakpoints (extra small), small, medium, large, and extra large.
Breakpoints are based on minimum widths, meaning they apply to that one tier and all those above it For example: .col-sm-4 would apply to small, medium, large, and extra large devices OR .col-md-6 would apply to medium, large & extra large screens only.
You can also mix and match breakpoints so for example your layout might allow 1 column up to medium screens, then 2 columns for medium and 4 columns for large and above screens. ie class="col-12 col-md-6 col-lg-3"
| Breakpoint | Shortname | Description | Media queries | Column Class Examples |
|---|---|---|---|---|
| 1. Extra Small (default) | (blank) | Extra small devices (portrait phones, less than 576px) | No media query since this is the default in Bootstrap | .col-(1-12) |
| 2. Small | sm |
Small devices (landscape phones, 576px and up) | @media (min-width: 576px) {} |
.col-sm-(1-12) |
| 3. Medium | md |
Medium devices (tablets, 768px and up) | up: @media (min-width: 768px) {}down: @media (max-width: 767px) {}
|
.col-md-(1-12) |
| 4. Large | lg |
Large devices (desktops, 992px and up) | @media (min-width: 992px) {} |
.col-lg-(1-12) |
| 5. Extra Large | xl |
Extra large devices (large desktops, 1200px and up) | @media (min-width: 1200px) {} |
.col-xl-(1-12) |
Auto Column Widths
With the power of Flexbox you can simply use any number of .col elements within a .row element and every column will automatically be made the same width.
1 of 2 1 of 2 1 of 3 1 of 3 1 of 3
Setting one column width
You can even set the width of one column and Flexbox will automatically resize the other columns around it.
View code example 1 of 3 2 of 3 (wider) 3 of 3 1 of 3 2 of 3 (wider) 3 of 3
Variable width content
Using the col-{breakpoint}-auto classes you can set fixed width columns on one breakpoint and then reset them to their nature width on another breakpoint.
1 of 3 Variable width content 3 of 3 1 of 3 Variable width content 3 of 3
Equal-width multi-row
Create equal-width columns that span multiple rows by inserting a .w-100 where you want the columns to break to a new line.
col col col col
Responsive Layouts
All breakpoints
For grid layouts that are the same from the smallest of devices to the largest, use the .col and .col-* classes.
col col col col col col col col-6 col-8 col-4
Stacked to horizontal
Using a single set of .col-sm-* classes, you can create a basic grid system that starts out stacked on extra small devices before becoming horizontal on desktop (medium) devices.
col-sm-8 col-sm-4 col-sm col-sm col-sm
Mix it up!
Combine .col-BREAKPOINT-* classes on the same columns to create varying layouts per breakpoint.
.col .col-md-8 .col-6 .col-md-4 .col-6 .col-md-8 .col-6 .col-md-2 .col-6 .col-md-2 .col-6 .col-6
Alignment
Vertical Alignment/Tools
The following classes applied to any .row elements allows you to control the vertical alignment of columns in a grid.
-
.align-items-startandalign-items-BREAKPOINT-start:
aligns columns to the top ("start"). -
.align-items-endandalign-items-BREAKPOINT-end:
aligns columns to the bottom ("end"). -
.align-items-centerandalign-items-BREAKPOINT-center:
aligns columns to the middle ("center"). -
.align-items-stretchandalign-items-BREAKPOINT-stretch:
stretches column to the full height of their row container.
You can also align single columns using the .align-self-start|end|center|stretch and .align-self-BREAKPOINT-start|end|center|stretch classes directly on the column elements.
Align top Align top Align center Align center Align bottom Align bottom Stretch full height Stretch full height Single column top Single column middle Single column bottom
Horizontal Alignment/Tools
The following classes applied to any .row elements allows you to control the horizontal alignment of columns in a grid.
-
.justify-content-startandjustify-content-BREAKPOINT-start:
aligns columns to the left ("start"). -
.justify-content-endandjustify-content-BREAKPOINT-end:
aligns columns to the right ("end"). -
.justify-content-centerandjustify-content-BREAKPOINT-center:
aligns columns to the center ("center"). -
.justify-content-aroundandjustify-content-BREAKPOINT-around:
centers columns and distributes them evenly. -
.justify-content-betweenandjustify-content-BREAKPOINT-between:
stretches columns to the full width of their row container and distributes them evenly.
Align left Align left Align center Align center Align right Align right Align even center Align even center Align even stretch Align even stretch
No gutters
By default columns have horizontal padding to add space or "gutters" between columns, you can remove this by adding the .no-gutters class to .row elements.
Gutters Gutters No Gutters No Gutters
Column Ordering
Flex order
If you're using Flexbox you can reorder columns without moving them in your code by using these classes: .flex-first , .flex-unordered and .flex-unordered
All classes are also responsive: .flex-BREAKPOINT-first|last|unorder so you can change the order per breakpoint too.
First, but unordered Second, but last Third, but first
Offsetting columns
Move columns to the right using .offset-BREAKPOINT-VALUE(1-12) classes. These classes increase the left margin of a column by VALUE(1-12) columns. For example, .offset-md-4 moves .col-md-4 over four columns.
.col-md-4 .col-md-4 .offset-md-4 .col-md-3 .offset-md-3 .col-md-3 .offset-md-3 .col-md-6 .offset-md-3
Push and pull
If you have more complex ordering needs you can use the built-in grid columns with .push-BREAKPOINT-VALUE(1-12) and .pull-BREAKPOINT-VALUE(1-12) modifier classes. These literally push or pull columns into a new order.
1st column: .col-md-9 .push-md-3 2nd column: .col-md-3 .pull-md-9
Grid Nesting
You can "nest" grids within grids by following the .row > .col structure.
Level 1: .col-sm-9 Level 2: .col-8 .col-sm-6 Level 3: .col-6 Level 3: .col-6 Level 2: .col-4 .col-sm-6


