UI ELEMENTS
As of version 3.0.0 we have an alternative style sheet that uses the Flexible box layout mode and is packed with new and exciting features.
The Flexible box layout mode, or flexbox, introduces some very interesting features that we've used in Ink. Most of them are relative to the grid system but as you probably know, or will find out, that means they affect many other components in the framework.
These new features include:
On this page we'll cover all the places where flexbox feature enhancement exists and how to take advantage of them.
Be aware that the Flexible box layout mode is still at the Candidate Recommendation stage of the specification and even though the W3C encourages browser makers to implement it, it is subject to change before the final version of the specification.
Ink-flex.css is the file that contains the new flexbox features, so the first step is to link it on your document head
:
Code
In the example above we're calling the css from our cdn but if you want to host the files yourself, just put them wherever you like and set the propper url.
ink-flex.css
or ink-flex.min.css
don't contain css for browsers without flexbox support, so if you still want or need to have a fallback for older browsers we have a ink-legacy.css
file that contains all the non-flexbox code where all the rules have html.no-flexbox, html.no-flexboxlegacy
as part of the selector:
Code
We can now use the included modernizr.js to detect if the browser does not support flexbox and load the lecagy stylesheet if needed:
Code
Include the code above right before closing body
tag. Modernizr will detect if the browser supports flexbox, and if it doesn't it will write the no-flexbox
and / or no-flexboxlegacy
css classes on the html
element and load the legacy css file.
This approach has a major drawback. Older browsers will have to load an additional css file, but we prefer to "penalize" browsers that don't support flexbox rather than the ones that do. There are other ways to implement this, but they have their own drawbacks, so we'll let you choose the one that fits your needs the best.
Class name | Description |
---|---|
ink-flex |
Defines an element as a flex container. |
push-top |
Aligns an element to the top of its flexbox container. |
push-middle |
Aligns an element to vertical center of its flexbox container. |
push-bottom |
Aligns an element to vertical bottom of its flexbox container. |
push-left |
Aligns an element to the left of its flexbox container. |
push-center |
Aligns an element to horizontal center of its flexbox container. |
push-right |
Aligns an element to the right its flexbox container. |
order-# |
Sets the display order for up to 10 elements. When used you have to set the order for all elements inside the parent container. |
reverse |
Inverts the display order of the flexbox containers children. Defaults to the x axis. |
vertical |
Sets the flow inside a flexbox container to the y axis. Items will display vertically. Can be combined with reverse to invert element order. |
all-auto |
Sets the elements width to auto for all breakpoints. Horizontal space will be divided evenly between elements as content size allows. |
tiny-auto |
Sets the elements width to auto for the 'tiny' breakpoint. Horizontal space will be divided evenly between elements as content size allows. |
small-auto |
Sets the elements width to auto for the 'small' breakpoint. Horizontal space will be divided evenly between elements as content size allows. |
medium-auto |
Sets the elements width to auto for the 'medium' breakpoint. Horizontal space will be divided evenly between elements as content size allows. |
large-auto |
Sets the elements width to auto for the 'large' breakpoint. Horizontal space will be divided evenly between elements as content size allows. |
xlarge-auto |
Sets the elements width to auto for the 'xlarge' breakpoint. Horizontal space will be divided evenly between elements as content size allows. |
large-class-name
.If you're not familiar with our grid system, we advise you to read its documentation before going ahead.
When using our flexbox style sheet the column-group
element is, by default, a flex container so, you don't need to use the ink-flex
css class, in this case:
Code
Unlike the "default" grid system, and because of the way flexbox works, positioning classes are applied to the column-group
, rather that the columns themselves.
Demo
You can also define breakpoint dependent grid column alignment:
Code
Demo
You can combine horizontal and vertical alignment classes to center a grid column in both the x and y axis:
Code
Demo
Flexbox allows us to redefine the order that grid columns are displayed, regardless of their order in the markup.
Code
The only drawback is that if you want to reorder grid columns, you'll have to set the order for all within the column-group
. This is so because setting the order
property takes the element out of the normal flexbox flow so, setting the order for just one would result in having that element to be the first and the rest would just be show by their order in the markup.
Demo
Once again you can reorder items based, on the breakpoint:
Code
Demo
With flex box you can reverse the order of elements inside a column-group
without having to specify the order for all columns. Also you can set if elements flow along either the x or y axis of the column-group
. In the example below, adding the reverse
css class to the column-group
will reverse the order of its column along the x axis:
Code
Demo
Adding the vertical
css class to the column-group
will make its child columns flow along the y axis. Basically each column will be in a single "line" regardless of their width. Combined with the reverse
css class elements will flow vertically in reverse order:
Code
Demo
Code
Demo