Scaffolding
IOUI is built on responsive 12-column grids, layouts, and components.
Grid system
IOUI uses the fluid (responsive) grid system from Bootstrap and utilizes 12 columns. The grid adapts to be 724px and 1170px wide depending on your viewport. Below 767px viewports, the columns become fluid and stack vertically.
The fluid grid system uses percents instead of pixels for column widths. It has the same responsive capabilities as Bootstrap's fixed grid system, ensuring proper proportions for key screen resolutions and devices.
Basic fluid grid HTML
For a simple two column layout, create a .row-fluid
and add the appropriate number of .span*
columns. As this is a 12-column grid, each .span*
spans a number of those 12 columns, and should always add up to 12 for each row (or the number of columns in the parent).
<div class="row-fluid"> <div class="span4">...</div> <div class="span8">...</div> </div>
Fluid offsetting
Move columns to the right using .offset*
classes. Each class increases the left margin of a column by a whole column. For example, .offset4
moves .span4
over four columns.
<div class="row-fluid"> <div class="span4">...</div> <div class="span4 offset2">...</div> </div>
Fluid nesting
To nest your content with the default grid, add a new .row
and set of .span*
columns within an existing .span*
column.
Each nested level of columns should add up to 12 columns. This is because the fluid grid uses percentages, not pixels, for setting widths.
<div class="row-fluid"> <div class="span12"> Fluid 12 <div class="row-fluid"> <div class="span6"> Fluid 6 <div class="row-fluid"> <div class="span6">Fluid 6</div> <div class="span6">Fluid 6</div> </div> </div> <div class="span6">Fluid 6</div> </div> </div> </div>
Responsive design
About responsive Bootstrap
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
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 |
---|---|---|---|
Large display | 1200px and up | 70px | 30px |
Default | 980px and up | 60px | 20px |
Portrait tablets | 768px and above | 42px | 20px |
Phones to tablets | 767px and below | Fluid columns, no fixed widths | |
Phones | 480px and below | Fluid columns, no fixed widths |
/* Large desktop */ @media (min-width: 1200px) { } /* Portrait tablet to landscape and desktop */ @media (min-width: 768px) and (max-width: 979px) { ... } /* Landscape phone to portrait tablet */ @media (max-width: 767px) { ... } /* Landscape phones and down */ @media (max-width: 480px) { ... }
Responsive utility classes
For faster mobile-friendly development, use these utility classes for showing and hiding content by device. Below is a table of the available classes and their effect on a given media query layout (labeled by device). They can be found in responsive.less
.
Class | Phones 767px and below | Tablets 979px to 768px | Desktops Default |
---|---|---|---|
.visible-phone |
Visible | Hidden | Hidden |
.visible-tablet |
Hidden | Visible | Hidden |
.visible-desktop |
Hidden | Hidden | Visible |
.hidden-phone |
Hidden | Visible | Visible |
.hidden-tablet |
Visible | Hidden | Visible |
.hidden-desktop |
Visible | Visible | Hidden |
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. Responsive utilities should not be used with tables, and as such are not supported.
Responsive utilities test case
Resize your browser or load on different devices to test the above classes.
Visible on...
Green checkmarks indicate that class is visible in your current viewport.
- Phone✔ Phone
- Tablet✔ Tablet
- Desktop✔ Desktop
Hidden on...
Here, green checkmarks indicate that class is hidden in your current viewport.
Responsive JavaScript
Sometimes it is necessary to change the behaivor in your client-side JavaScript depending on how your application is displayed in the current viewport.
We have included an IOUI.responsive
object which correspods to Bootstrap's supported devices which you can use to test the device's current resolution using the matchMedia
object.
Learn more about using media queries from code here.
Example
function responsiveTest(mql) { if (mql.matches) { // The current viewport is 480 px and below } else { } } // The following properties are available which corresponds to the supported devices table above // LargeDisplay // Default // PortraitTablet // PhoneToTablet // LandscapePhone // PortraitPhone // Usage: Use a matchMedia listener to capture changes in the current display matchMedia(IOUI.responsive.LandscapePhone).addListener(responsiveTest); // Make an initial query responsiveTest(matchMedia(IOUI.responsive.LandscapePhone));