Responsive
Spectre provides a neat responsive layout grid system and responsive visibility utilities.
Modifiers
The following class name modifiers can be applied to some class names:
xs
- 480pxsm
- 600pxmd
- 840pxlg
- 960pxxl
- 1280px
On this page, the classes which will be affected by these modifiers are:
col-<size>-<1-12>
- columnsgrid-<size>
- containershide-<size>
- hide belowshow-<size>
- show below
Demo
The following markup combines columns and showing/hiding for different breakpoints.
Resize the window to see:
Spectre also has a responsive testing tool which you can use online or locally by cloning the repo.
Columns
The column
and col-*-*
classes create responsive columns for various breakpoints:
<div class="container">
<div class="columns">
<div class="column col-xs-6">col-xs-6</div>
<div class="column col-xs-3">col-xs-3</div>
<div class="column col-xs-3">col-xs-3</div>
</div>
</div>
The base classes apply to columns for any window width:
col-<1-12>
all windows
The following 5 variants apply to columns when the window width is less than or equal to:
col-xs-<1-12>
- 480pxcol-sm-<1-12>
- 600pxcol-md-<1-12>
- 840pxcol-lg-<1-12>
- 960pxcol-xl-<1-12>
- 1280px
Container
The responsive layout also provides fixed-width containers:
<!-- 100% width container with max-width set to grid-lg (960px) -->
<div class="container grid-lg">
<div class="columns">
...
</div>
</div>
Add the following classes to the .container
for a fixed-width container limited to specific max-widths:
grid-xs
- 480pxgrid-sm
- 600pxgrid-md
- 840pxgrid-lg
- 960pxgrid-xl
- 1280px
Visibility
The responsive visibility utilities help show and hide elements on specific viewport sizes.
Hiding content
Resize the window to see the table headings turn on as the window gets narrower:
size-xs | size-sm | size-md | size-lg | size-xl | |
---|---|---|---|---|---|
hide-xs | |||||
hide-sm | |||||
hide-md | |||||
hide-lg | |||||
hide-xl |
The following 5 variants hide elements when the window width is less than or equal to:
hide-xs
- 480pxhide-sm
- 600pxhide-md
- 840pxhide-lg
- 960pxhide-xl
- 1280px
Showing content
Resize the window to see the table headings turn on as the window gets wider:
size-xs | size-sm | size-md | size-lg | size-xl | |
---|---|---|---|---|---|
show-xs | |||||
show-sm | |||||
show-md | |||||
show-lg | |||||
show-xl |
The following 5 variants show elements when the window width is less than or equal to:
show-xs
- 480pxshow-sm
- 600pxshow-md
- 840pxshow-lg
- 960pxshow-xl
- 1280px