Modulifier cheat sheet
Responsive setup
-
CSS viewport & text size
Will includes all the
@viewportcode.Will set
text-size-adjustto prevent browsers from zooming text.
-
Border box
Will add all the
border-boxcode to change the layout math.
-
Body margin
Will remove the default
marginfrom<body>because it is almost never used.
-
New HTML elements
Will set default styles for new HTML elements for better browser support.
Images
-
Remove border
Will remove the border from all images by default for better browser support.
-
.img-flexCreates the responsive
.img-flexclass that will make images100%the width of their container.
-
SVG helpers
Will fix a browser bug related to embedded SVG.
Add the ability for embedded SVG to inherit
fillfrom the CSScolorproperty.
-
.image-replacement,.irA class, and a shorter version, that will hide all the text inside an element and allow only the
background-imageto show.
List group
These classes are brute force and not responsive, if you use list-group-inline, the list will always be inline.
-
.list-groupThe
.list-groupclass that will remove bullets and padding from lists, so semantically they can be lists but no visually.When added to a
<dl>tag, there is a little responsiveness to how the<dt>and<dd>tags flow.
-
.list-group-inlineThe
.list-group-inlineclass that will force the<li>tags onto the same line.When added to the
<dl>tag, the<dt>and<dd>tags will sit on the same line if there is enough space.
-
List group example
<ul class="list-group-inline"> <li><a href="#">Dinosaurs</a></li> <li><a href="#">Plant eaters</a></li> <li><a href="#">Meat eaters</a></li> </ul><dl class="list-group-inline"> <dt>Length</dt> <dd>12 metres</dd> <dt>Mass</dt> <dd>5.4 metric tons</dd> </dl>
Embed containers
-
.embedThe wrapper class for making responsive embedded resources like images and videos.
-
.embed-itemThe class to be added directly to the embedded image or video.
-
Embed container example
<figure> <div class="embed embed-4by3"> <img class="embed-item" src="dinos.jpg" alt=""> </div> <figcaption>Dinosaurs frolicking in the barren landscape</figcaption> </figure><div class="embed embed-16by9"> <video class="embed-item" src="dinos-frolicking.mp4" controls></video> </div>
-
.embed-1by1Square.
-
.embed-4by3Traditional TV/computer screens.
-
.embed-iso216A-standard paper sizes.
-
.embed-3by2Classic 35 mm film & most digital photos, landscape.
-
.embed-2by3Classic 35 mm film & most digital photos, portrait.
-
.embed-goldenThe Golden Ratio.
-
.embed-16by9HDTV.
-
.embed-185by100Common widescreen cinema.
-
.embed-24by10Widescreen cinema: 2.4:1.
-
.embed-3by1Panorama photos.
-
.embed-4by1Polyvision.
-
.embed-5by1Really, really wide…
-
Making a new ratio
Take the height, divide by the width, and multiply by 100 —
h ÷ w × 100An image with the dimensions: 950 × 1427:
1427 ÷ 950 × 100 = 105%
Media objects
-
.mediaA wrapper class to surround image & text groups, especially if the images is to be beside the text.
-
.media-imgA class for adding to the image, or surrounding
<div>, within the media object.
-
.media-bodyA class to add to the text, or surrounding
<div>, within the media object.
-
.media-img-reversedInstead of floating the image left it will
float: right
-
.media-img-stackedWill disable floating and have the image above the text instead.
-
Media object example
<div class="media"> <div class="media-img media-img-reversed"> <img src="images/parsnips.jpg" alt=""> </div> <div class="media-body"> <h2 class="media-title">Parsnips</h2> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p> </div> </div>
Icons
-
.iconTo be added to a tag, usually
<i>to mark it as being an icon.Usually you add another class to define the
background-imageWill also add some CSS to support embedded SVG icons with the
<svg>and<use>tags.
-
.icon-labelCan be added to the neighbouring text to allow the icon and the text to align.
-
.icon-linkCan be added to the surrounding
<a>tag to remove thetext-decoration
-
.i-16A 16 × 16 pixel sized icon.
-
.i-18A 18 × 18 pixel sized icon.
-
.i-20A 20 × 20 pixel sized icon.
-
.i-24A 24 × 24 pixel sized icon.
-
.i-32A 32 × 32 pixel sized icon.
-
.i-48A 48 × 48 pixel sized icon.
-
.i-64A 64 × 64 pixel sized icon.
-
.i-96A 96 × 96 pixel sized icon.
-
.i-128A 128 × 128 pixel sized icon.
-
.i-192A 192 × 192 pixel sized icon.
-
.i-256A 256 × 256 pixel sized icon.
-
Icons with
<img>tags<ul> <li> <i class="icon i-18"> <img src="images/icon.svg" alt=""> </i> <span class="icon-label">GitHub</span> </li> </ul>
-
Icons with background images
<a class="icon-link" href="#"> <i class="icon i-32 i-github"></i> <span class="icon-label">GitHub</span> </a>.i-github { background-image: url("../img/github.svg"); }
-
Icons with SVG symbols
<svg hidden> <symbol id="the-icon" viewBox="0 0 256 256"> <circle x="128" y="128" r="128" /> </symbol> </svg> ⋮ <a class="icon-link" href="#"> <i class="icon i-24"> <svg><use xlink:href="#the-icon"></use></svg> </i> <span class="icon-label">GitHub</span> </a>
-
Icons with SVG symbols in a separate file
<a class="icon-link" href="#"> <i class="icon i-24"> <svg><use xlink:href="images/icons.svg#the-icon"></use></svg> </i> <span class="icon-label">GitHub</span> </a>
Hidden
-
[hidden],.hiddenMakes sure the
hiddenattribute works in all browsers and provides a.hiddenclass.
-
.visually-hiddenA class that will hide something from the visual screen but still allow it to be accessible via tools.
-
.focusableTo be added to the
.visually-hiddenclass to allow the keyboard to access the element.
-
.invisibleA class that will hide an element on the screen, but its space will still be there.
-
.chop,.cropThese classes that will chop/crop overflowing elements off—essentially just
overflow: hidden
-
.truncateA class that will chop single lines of text off and add an ellipsis at the end.
-
.scrollableA class that make an element horizontally scrollable, good for simple responsive tables.
Positioning
These classes are brute force and not responsive, if you use left, the element will always be floated left.
-
.flex-rowConvert the element into a Flexbox container.
-
.flex-justifyTurn on Flexbox’s
justify-content: space-betweenproperty.
-
.flex-align-centerTurn on Flexbox’s
align-items: centerproperty.
-
.clearfixA class that can be used on floating wrappers to trigger a clear fix.
-
.left,.rightWill
floatthe element to theleftor theright
-
.inline,.inline-block(.ib),.blockClasses to control the
displayproperty betweeninline,inline-block, andblock
-
.valign-top,.valign-middle,.valign-bottomThese classes allow you to control the
vertical-alignproperty oninlineandinline-blockelements or within tables.
-
.fixed,.relative,.absolute,.staticClasses to control the
positionproperty of an element.
-
.zindex-1,.zindex-2,.zindex-3,.zindex-1000Classes to control three basic
z-indexstates on an element.
-
.pin-left-top,.pin-right-top,.pin-left-bottom,.pin-right-bottom,.pin-center-top,.pin-center-bottom,.pin-left-center,.pin-right-center,.pin-centerA series of classes for moving a
position: absoluteelement to different common locations.The
.pin-*classes will automatically addposition: absoluteso adding the class.absolutealso isn’t necessary.Simplified versions are available:
.pin-lt,.pin-rt,.pin-lb,.pin-rb,.pin-ct,.pin-cb,.pin-lc,.pin-rc,.pin-c
-
.width-quarter,.width-half,.width-fullA series of classes for setting common widths.
Simplified versions are available:
.w-1-4,.w-1-2,.w-1
-
.height-quarter,.height-half,.height-fullA series of classes for setting common heights—usually only useful the context of
position: absoluteSimplified versions are available:
.h-1-4,.h-1-2,.h-1
-
.height-win-quarter,.height-win-half,.height-win-fullA series of classes for setting elements to have a minimum height compared to the window size.
.height-win-fullwill be the same height as the window itself.Simplified versions are available:
.h-w-1-4,.h-w-1-2,.h-w-1
-
.center-flow,.center-textCentres
inline,inline-block& text elements—essentially just addstext-align: center
-
.center-blockCentres block-level elements, but they need widths—essentially adds:
margin-left: auto; margin-right: auto
-
.center-content,.center-content-verticalCentres all the contents of a box within, both vertically & horizontally centered.
If there are multiple elements they are put on new lines, creating a single column.
-
.center-content-horizontalCentres all the contents of a box within, both vertically & horizontally centered.
If there are multiple elements they are put on a single line, creating a row column.
-
.not-centered,.no-auto-marginsRemoves the auto margins from the left & right side by setting them to
0
Nice lists
-
Typographic bullets & numbers
The “Nice lists” option will change the default bullets and numbers on
<ul>and<ol>tags to make them look better.
-
Remove custom bullets & numbers
The simplest way to remove the custom bullets & numbers is to add the class
.list-group
Basic buttons
-
.btnA very basic button style for prototyping websites.
-
.btn-lightAn alternative button style for prototyping websites.
-
.btn-ghostA third button style for prototyping websites.
-
.link-boxFor adding to
<a>tags to remove their underlines and make them block.
-
Button examples
<a class="btn" href="#">Buy Now</a> <a class="btn btn-ghost" href="#">See all the features</a>
Forms
-
Form normalization
Will normalize a bunch of browser inconsistencies when styling forms and inputs.
Will set all labels to the most accessible visual design format: above inputs—except checkboxes and radio buttons, they will stay beside.
-
.label-blockA class to force a
<label>onto its own line.
-
.label-inlineA class to force a
<label>onto the same line as other inputs.
-
Customized input controls
Radio buttons & checkboxes are customized with larger, consistent looking controls.
Select boxes are customized with a consistent look.
-
.hide-custom-inputThis class can be added to a checkbox or radio button
<input>or<label>to hide the custom control.
Accessibility
-
Focus styles
Will add strong visual focus styles to links, buttons, inputs and focusable items.
-
Skip links
Adds all the CSS necessary for creating basic skip links.
-
Skip links example
<ul class="skip-links"> <li><a href="#main">Jump to main content</a></li> <li><a href="#nav">Jump to main navigation</a></li> <li><a href="#pause">Pause all animations</a></li> </ul>
Print styles
-
Print style normalization
Will do a bunch of default things to print styles including: removing shadows, setting text colour to black, removing backgrounds, adding underlines, displaying URLs beside links, and attempting to avoid orphans where possible.
-
.no-printWill hide the element when a user prints out the website.
-
.no-print-hrefWill stop the
hrefprinting out beside a link when printed.
-
.print-onlyWill hide an element by default but then display it when the website is printed.
-
.force-printWill attempt to force something to be printed even if there’s JavaScript or some other CSS that tries to hide it.
-
.page-break-beforeWill force a page-break before this content when printed.
-
.page-break-afterWill force a page-break after this content when printed.
-
.no-page-break-insideWill attempt to prevent the content from being broken over multiple pages when printed.