Utility

A collection of useful utility classes to style your content.

Container

Add the .uk-container class to a block element to give it a max-width and wrap the main content of your website. For large screens it applies a different max-width.


Centering

To center the container, use the .uk-container-center class. For any other block element, you additionally need to apply a width.

Example

Centered block element

Markup

<div class="uk-width-medium-1-2 uk-container-center">...</div>

Clearing and floating

Floating is fundamental for creating all kinds of layouts. But floats need to be cleared or in the worst case, you might end up with a scrambled site. The following classes will help you to setup basic layouts.

ClassDescription
.uk-float-leftFloat the element to the left.
.uk-float-rightFloat the element to the right.
.uk-clearfixAdd this class to a parent container to clear floats.

Markup

<div class="uk-clearfix">
    <div class="uk-float-right">...</div>
    <div class="uk-float-left">...</div>
</div>

New block formatting context

Instead of using the .uk-clearfix class, you can create a new block formatting context to clear floats. Depending on your setup, you can evaluate which method is more suited.

ClassDescription
.uk-nbfcSets overflow to hidden to create a new block formatting context.
.uk-nbfc-altSets display to table-cell to create a new block formatting context.

Alignment of images and objects

Align images or other elements with spacing between the text and the element.

ClassDescription
.uk-align-leftFloats the element to the left and creates right and bottom margin.
.uk-align-rightFloats the element to the right and creates left and bottom margin.
.uk-align-medium-leftOnly affects device widths of 768px and higher.
.uk-align-medium-rightOnly affects device widths of 768px and higher.
.uk-align-centerCenters the element and creates bottom margin.

Example

Image aligned to the rightLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Markup

<p class="uk-clearfix">
    <img class="uk-align-medium-right" src="" alt="">
    ...
</p>

Vertical alignment

To align objects vertically, you need to create a parent container to which the object itself will be aligned.

ClassDescription
.uk-vertical-alignAdd this class to the parent container. This container needs a specific height.
.uk-vertical-align-middleAdd this class to the child element to center your content.
.uk-vertical-align-bottomAdd this class to the child element to align your content to the bottom.
.uk-height-1-1This helper class applies a height of 100%.

Example

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Markup

<div class="uk-vertical-align">
    <div class="uk-vertical-align-middle">
    ...
    </div>
</div>
<div class="uk-vertical-align">
    <div class="uk-vertical-align-bottom">
    ...
    </div>
</div>

NOTE The object you align needs to have a width or max-width that is smaller than its parent container.

Center the entire page

The .uk-height-1-1 class comes in handy, if you want to extend the <html> and <body> elements to the full height of the page. This can be very useful when creating error pages.

Markup

<html class="uk-height-1-1">
    ...
    <body class="uk-height-1-1">
        <div class="uk-vertical-align">
            <div class="uk-vertical-align-middle">...</div>
        </div>
    </body>
</html>

Center horizontally

To center your content horizontally as well, add the .uk-text-center class to the parent and the .uk-container-center class to the child element. This is necessary because of the responsive behavior.


Viewport height

To create a container that fills the height of the entire viewport, for example for fullscreen image or video teasers, just add the .uk-height-viewport class.


Position elements

UIkit provides a number of classes to position your content without having to add your own CSS.

ClassDescription
.uk-position-topPositions an element absolute at the top.
.uk-position-bottomPositions an element absolute at the bottom.
.uk-position-coverAdds absolute positioning to an element and stretches it to cover the entire parent.
.uk-position-relativeAdds relative positioning to an element.

Responsive objects

Images in UIkit adapt to the width of their parent container by default. If you want to apply the responsive behavior to media elements, like a video object, just add one of the following classes.

ClassDescription
.uk-responsive-widthAdjusts the object’s width according to its parent’s width, keeping the original aspect ratio.
.uk-responsive-heightAdjusts the object’s height according to its parent’s height, keeping the original aspect ratio.

NOTE The .uk-responsive-width class can also be applied to an Iframe, provided its width and height attributes are set.

Example width

Example height

Markup

<video controls class="uk-responsive-width"></video>

<img class="uk-responsive-height" src="" alt="">

Margin

Add one of the following classes to add spacing to block elements.

ClassDescription
.uk-marginAdds the same top and bottom margins as a paragraph usually has.
.uk-margin-topAdds top margin.
.uk-margin-bottomAdds bottom margin.
.uk-margin-leftAdds left margin.
.uk-margin-rightAdds right margin.

Larger margin

Add one of the following classes to add larger spacing to block elements.

ClassDescription
.uk-margin-largeAdds large top and bottom margin.
.uk-margin-large-topAdds large top margin.
.uk-margin-large-bottomAdds large bottom margin.
.uk-margin-large-leftAdds large left margin.
.uk-margin-large-rightAdds large right margin.

Smaller margin

Add one of the following classes to add smaller spacing to block elements.

ClassDescription
.uk-margin-smallAdds small top and bottom margin.
.uk-margin-small-topAdds small top margin.
.uk-margin-small-bottomAdds small bottom margin.
.uk-margin-small-leftAdds small left margin.
.uk-margin-small-rightAdds small right margin.

Remove margin

Add one of the following classes to remove spacing from block elements.

ClassDescription
.uk-margin-removeRemoves all margins.
.uk-margin-top-removeRemoves top margin.
.uk-margin-bottom-removeRemoves bottom margin.

Auto margin

To add spacing to stacking elements, for example inline elements that wrap on smaller vieports, just add the data-uk-margin attribute to their parent container. It will automatically add the .uk-margin-small-top to the lower element.

Example

Markup

<p data-uk-margin>
    <button class="uk-button">...</button>
    <button class="uk-button">...</button>
</p>

NOTE By default, the data attribute adds the .uk-margin-small-top class to stacking elements. To apply a bigger margin, just add the {cls:'.uk-margin-top'} option.


Border radius

To add rounded corners to an element, like an image, just add the .uk-border-rounded. To a apply a circled shape, add the .uk-border-circle class.

Example

Border rounded Border circle

<img class="uk-border-rounded" src="" alt="">
<img class="uk-border-circle" src="" alt="">

Heading large

To increase the font size of your headings on tablets and desktops, just add the .uk-heading-large class.

Example

Heading

Markup

<h1 class="uk-heading-large">...<h1>

If a link should not have the default link color, just add the .uk-link-muted class to the anchor element or the parent element.

Example

Markup

<a class="uk-link-muted">...<a>

<h1 class="uk-link-muted"><a>...<a><h1>

<ul class="uk-link-muted">
    <li><a>...<a></li>
    <li><a>...<a></li>
    <li><a>...<a></li>
</ul>

Scrollable preformatted text

Add the .uk-scrollable-text class to set a max-height and provide a vertical scrollbar. This is very useful for preformatted text, if you don’t want your code blocks to take too much space.

Example

<!-- This is sample code to demonstrate preformatted text with a scrollbar. -->

<div class="uk-grid">
    <div class="uk-width-medium-1-2">
        <div class="uk-panel uk-panel-box uk-text-left">...</div>
    </div>
    <div class="uk-width-medium-1-2">
        <div class="uk-panel uk-panel-box uk-text-right">...</div>
    </div>
</div>
<div class="uk-grid">
    <div class="uk-width-medium-1-2">
        <div class="uk-panel uk-panel-box uk-text-center">...</div>
    </div>
    <div class="uk-width-medium-1-2">
        <div class="uk-panel uk-panel-box uk-text-justify">...</div>
    </div>
</div>

<div class="uk-grid">
    <div class="uk-width-medium-1-2">
        <div class="uk-panel uk-panel-box uk-text-break">...</div>
    </div>
    <div class="uk-width-medium-1-2">
        <div class="uk-panel uk-panel-box"><p class="uk-margin-remove uk-text-truncate">...</p></div>
    </div>
</div>

Scrollable box

Add the .uk-scrollable-box class to create a panel-like box which has a max-height and provides a vertical scrollbar. It can contain any kind of content.

Example

Markup

<div class="uk-scrollable-box">
    <ul class="uk-list">
        <li><label><input type="checkbox">...</label></li>
        <li><label><input type="checkbox">...</label></li>
    </ul>
</div>

Overflow container

To create a container that provides a horizontal scrollbar whenever the elements inside it are wider than the container itself, just add the .uk-overflow-container class to a <div> element. This comes in useful when having to handle tables on a responsive website, which at some point would just get too big.

Example

Table HeadingTable HeadingTable HeadingTable HeadingTable HeadingTable HeadingTable HeadingTable Heading
Table FooterTable FooterTable FooterTable FooterTable FooterTable FooterTable FooterTable Footer
Table DataTable DataTable DataTable DataTable DataTable DataTable DataTable Data
Table DataTable DataTable DataTable DataTable DataTable DataTable DataTable Data
Table DataTable DataTable DataTable DataTable DataTable DataTable DataTable Data

Markup

<div class="uk-overflow-container">...</div>

Display utilities

Add one of these classes to change the display properties of an element.

ClassDescription
.uk-display-blockForces the element to behave like a block element.
.uk-display-inlineForces the element to behave like an inline element.
.uk-display-inline-blockForces the element to behave like an inline-block element.

Visibility utilities

ClassDescription
.uk-hiddenHides the element on any device.
.uk-hidden-touchHides the element on touch devices.
.uk-hidden-notouchHides the element on non-touch devices.
.uk-invisibleHides the element without removing it from the flow.
.uk-visible-hoverDisplays hidden content on hover using display: block. Add this class to the parent element.
.uk-visible-hover-inlineDisplays hidden content on hover using display: inline-block. Add this class to the parent element.

Example

Hover me…
Bazinga!

Markup

<div class="uk-visible-hover">
    <div class="uk-hidden">...</div>
</div>

Responsive visibility

You can show or hide content on specific viewport widths. Breakpoints are set through variables and can easily be modified. Since the line between different device sizes keeps blurring, class names are kept general and do not refer to particular devices.

ClassSmall
(Phones)
up to 767
Medium
(Tablets)
768 to 959
Large
(Desktops)
960 and larger
.uk-visible-smallVisibleHiddenHidden
.uk-visible-mediumHiddenVisibleHidden
.uk-visible-largeHiddenHiddenVisible
.uk-hidden-smallHiddenVisibleVisible
.uk-hidden-mediumVisibleHiddenVisible
.uk-hidden-largeVisibleVisibleHidden

DISCLAIMER: MID CITY GYM DOES NOT GUARANTEE RESULTS, WHICH CAN VARY FROM INDIVIDUAL TO INDIVIDUAL.