Depending on the type of element you are styling, you can apply different types of positioning to them.
Some of the examples shown below have some abstract implications. If you are unfamiliar with the more intricate points of CSS,
feel free to ask your friendly resident front-end developer for advice. Just be sure to bring chocolate.
These classes will make elements be handled as if they were block, inline-block, or inline elements.
Alignment – Horizontal
These classes go on the parent container of the elements you want to align. You can align any inline content,
such as text, images, block elements displayed as inline-block, etc.
Alignment – Vertical
There are two types of vertical alignment, one where two sibling elements are aligned related to each other, and one where
a child is vertically aligned within its parent.
Vertically Aligned Siblings
To align two inline (or inline-block) elements, apply one the following classes to the element
which should act as reference point.
Vertically Aligned Children – Tables
For table cells (<th>/<td>, or any element with the display: table-cell CSS
property), apply the align-top, align-middle,
or align-bottom class to the cell to align its content.
Vertically aligned table content
<table>
<tbody>
<tr>
<td class="one-half align-middle">
This table cell is aligned "middle".
</td>
<td class="one-half">
This is non-aligned text that is really
just here to make one table cell larger
than the other so you can see the
effect on the other side.
</td>
</tr>
</tbody>
</table>
This table cell is aligned "middle".
This is non-aligned text that is really
just here to make one table cell larger
than the other so you can see the
effect on the other side.
Vertically Aligned Children – Centered Elements
If you need to center an element, you can also use the vertical-center
helper. It will turn your element into an inline-block element and center it alongside a blank dummy
element.
This is especially useful if you need to center an element whose height you don't know, e.g. because it is user-generated,
or its content differs depending on the state of your page.
You can apply a specific height to your vertical-center-container. If no height is specified,
it will be 100% of its parent height.
Please note that due to how browsers render inline elements, this will work only if the centered element does
not exceed the width of the parent container, minus the width of a space character.
Floats
If you want to make your elements float, you can use the classes float-left and float-right
To reset an existing float state of an element, you can use the float-none class.
Clearing Floats
You can clear floating elements on either side using the classes clear-left, clear-right
or clear-both.
Containing Floats
Since floating elements are outside of the normal element flow, they may sometimes not be properly contained by their
parent element.
To force an element to contain all of its floating descendants, use the clearfix
class.
Note: You can also clear elements toward the top by applying the clearfix-before
class.
Hiding Elements
You can hide elements from the document to hide content that is currently unavailable or unimportant,
to spare the user content that is not meant for human readers, to adjust your layout, etc.
The hide class will (visually) remove the element from the document and make the rest of the
document flow as it if weren't there.
Hiding Elements from Specific States
Since this is a very useful tool to improve the user experience for different devices, you can also hide elements
based on the state that the user is in.
To make an element disappear from specific states, add one or more of the usual state prefixes palm-,
lap- or desk-.
Temporarily Invisible Elements
Sometimes, you may want to temporarily hide an inactive part of the interface, but keep a blank area
in its place to maintain the page layout. For such cases, you can use the invisible class.
Miscellaneous
This section covers styling methods that are either self-explanatory, or so specific that explaining them in
detail should not be part of this documentation.
Examples in this section will offer no further explanation – please refer to your colleagues in front-end
development should you have any questions.