Example: Using Grid Units

Creating a layout using grids requires a yui3-g container and any number of yui3-u-* units. To create a layout that splits the available width into 2 equal parts, use two yui3-u-1-2 units. The last two numbers of the class name, "1-2", represent 1/2.

Note

The only child elements (e.g. direct descendants) of a yui3-g should be yui-3-u-* elements. Any elements within a yui3-g need to be wrapped in a yui3-u-* of some kind, otherwise you may experience side-effects due to the layout system being used.

Basic Markup Structure

<div class="yui3-g">
    <div class="yui3-u-1-2"></div>
    <div class="yui3-u-1-2"></div>
</div>

Provide a Content Container

Styling should be applied to a container within the unit, rather than the unit itself. This allows you to set borders, padding, margins (gutters), etc. without worrying about breaking the layout. For this demo we will give the content a class of content, but can be called whatever you like.

<div class="yui3-g">
    <div class="yui3-u-1-2">
        <div class="content">

        </div>
    </div>
    <div class="yui3-u-1-2">
        <div class="content">

        </div>
    </div>
</div>

Adding a Gutter

All units align edge to edge, with zero space in between. You can add space ("gutter"), by simply adding a margin to your content. This is where additional content styling, such as borders, padding, colors, etc. can be applied as well.

<style>
.yui3-g .content {
    border: 2px solid #000;
    margin-right:10px; /* "column" gutters */
    padding: 1em;
}
</style>

Available Units

Class Description
.yui3-u shrinks to fit content (unless given an explicit size)
.yui3-u-1 fills entire width of container
.yui3-u-1-2 fills 1/2 the container
.yui3-u-1-3 fills 1/3 the container
.yui3-u-2-3 fills 2/3 the container
.yui3-u-1-4 fills 1/4 the container
.yui3-u-3-4 fills 3/4 the container
.yui3-u-1-5 fills 1/5 the container
.yui3-u-2-5 fills 2/5 the container
.yui3-u-3-5 fills 3/5 the container
.yui3-u-4-5 fills 4/5 the container
.yui3-u-1-6 fills 1/6 the container
.yui3-u-5-6 fills 5/6 the container