Grid CSS - DeprecatedGrid CSS is a lightweight responsive and fluid layout utility optimized for mobile devices, tablets and desktops. Grid CSS is deprecated, use FlexGrid instead.
Documentation
Getting Started
Grid CSS is based on a 12 column layout. Columns are prefixed with ui-g-* and they should be a descendant of a container having ui-g class. A simple 3 column layout can be defined as;
<div class="ui-g">
<div class="ui-g-4">Col1</div>
<div class="ui-g-4">Col2</div>
<div class="ui-g-4">Col3</div>
</div>
Col1
Col2
Col3
Multi Line
When the number of columns exceed 12, columns wrap to a new line.
<div class="ui-g">
<div class="ui-g-6">Col1</div>
<div class="ui-g-6">Col2</div>
<div class="ui-g-6">Col3</div>
<div class="ui-g-6">Col4</div>
</div>
Col1
Col2
Col3
Col3
Same can also be achieved by having two ui-g containers to semantically define a row.
<div class="ui-g">
<div class="ui-g-6">Col1</div>
<div class="ui-g-6">Col2</div>
</div>
<div class="ui-g">
<div class="ui-g-6">Col3</div>
<div class="ui-g-6">Col4</div>
</div>
Col1
Col2
Col3
Col4
Nested
Columns can be nested to create more complex layouts.
<div class="ui-g">
<div class="ui-g-8 ui-g-nopad">
<div class="ui-g-6">6</div>
<div class="ui-g-6">6</div>
<div class="ui-g-12">12</div>
</div>
<div class="ui-g-4">4</div>
</div>
6
6
12
4
Direct children of ui-g has the same height automatically, in example above if the inside columns is likely to have different height with different content.
<div class="ui-g">
<div class="ui-g-8 ui-g-nopad">
<div class="ui-g-6">6 <br /><br /><br /> Content </div>
<div class="ui-g-6">6</div>
<div class="ui-g-12">12</div>
</div>
<div class="ui-g-4">4</div>
</div>
6 Content
6
12
4
Solution is wrapping the internal divs inside a ui-g as well.
<div class="ui-g">
<div class="ui-g-8 ui-g-nopad">
<div class="ui-g">
<div class="ui-g-6">6 <br /><br /><br /> Content </div>
<div class="ui-g-6">6</div>
<div class="ui-g-12">12</div>
</div>
</div>
<div class="ui-g-4">4</div>
</div>
6 Content
6
12
4
Responsive
Responsive layout is achieved by applying additional classes to the columns whereas ui-g-* define the default behavior. Four screen sizes are supported with different breakpoints.
Prefix | Devices | Media Query | Example |
---|---|---|---|
ui-sm- | Small devices like phones | max-width: 40em (640px) | ui-sm-6, ui-sm-4 |
ui-md- | Medium sized devices such as tablets | min-width: 40.063em (641px) | ui-md-2, ui-sm-8 |
ui-lg- | Devices with large screen like desktops | min-width: 64.063em (1025px) | ui-lg-6, ui-sm-12 |
ui-xl- | Big screen monitors | min-width: 90.063em (1441px) | ui-xl-2, ui-sm-10 |
Most of the time, ui-md- styles are used with default ui-g- classes, to customize small or large screens apply ui-sm, ui-lg and ui-xl can be utilized.
In example below, large screens display 4 columns, medium screens display 2 columns in 2 rows and default behavior gets only displayed in a mobile phone where each column is rendered in a separate row.
<div class="ui-g">
<div class="ui-g-12 ui-md-6 ui-lg-3">ui-g-12 ui-md-6 ui-lg-3</div>
<div class="ui-g-12 ui-md-6 ui-lg-3">ui-g-12 ui-md-6 ui-lg-3</div>
<div class="ui-g-12 ui-md-6 ui-lg-3">ui-g-12 ui-md-6 ui-lg-3</div>
<div class="ui-g-12 ui-md-6 ui-lg-3">ui-g-12 ui-md-6 ui-lg-3</div>
</div>
ui-g-12 ui-md-6 ui-lg-3
ui-g-12 ui-md-6 ui-lg-3
ui-g-12 ui-md-6 ui-lg-3
ui-g-12 ui-md-6 ui-lg-3
In this second example below, 3 columns are displayed in large screens and in medium screens first two columns are placed side by side where the last column displayed below them. In a mobile phone, they all get displayed in a separate row.
<div class="ui-g">
<div class="ui-g-12 ui-md-6 ui-lg-4">ui-g-12 ui-md-6 ui-lg-4</div>
<div class="ui-g-12 ui-md-6 ui-lg-4">ui-g-12 ui-md-6 ui-lg-4</div>
<div class="ui-g-12 ui-lg-4">ui-g-12 ui-lg-4</div>
</div>
ui-g-12 ui-md-6 ui-lg-4
ui-g-12 ui-md-6 ui-lg-4
ui-g-12 ui-lg-4
Padding
A column has a default padding by default, to remove it you may apply ui-g-nopad style class.
Offset
Offset classes allow defining a left margin on a column. Following sample adds a margin left to the second column for medium sized screens.
<div class="ui-g">
<div class="ui-g-12 ui-md-4">ui-g-12 ui-md-4</div>
<div class="ui-g-12 ui-md-4 ui-md-offset-4">ui-g-12 i-md-4 ui-md-offset-4</div>
</div>
The list of offset classes varying within a range of 1 to 12.
Prefix | Devices | Media Query | Example |
---|---|---|---|
ui-g-offset- | All devices | All screens | ui-g-offset-6, ui-g-offset-4 |
ui-sm-offset- | Small devices like phones | max-width: 40em (640px) | ui-sm-offset-6, ui-sm-offset-4 |
ui-md-offset- | Medium sized devices such as tablets | min-width: 40.063em (641px) | ui-md-offset-6, ui-md-offset-4 |
ui-lg-offset- | Devices with large screen like desktops | min-width: 64.063em (1025px) | ui-lg-offset-6, ui-lg-offset-4 |
ui-xl-offset-* | Big screen monitors | min-width: 90.063em (1441px) | ui-xl-offset-6, ui-xl-offset-4 |
Source
<h3 class="first">Basic</h3>
<div class="ui-g">
<div class="ui-g-1">1</div>
<div class="ui-g-1">1</div>
<div class="ui-g-1">1</div>
<div class="ui-g-1">1</div>
<div class="ui-g-1">1</div>
<div class="ui-g-1">1</div>
<div class="ui-g-1">1</div>
<div class="ui-g-1">1</div>
<div class="ui-g-1">1</div>
<div class="ui-g-1">1</div>
<div class="ui-g-1">1</div>
<div class="ui-g-1">1</div>
</div>
<div class="ui-g">
<div class="ui-g-2">2</div>
<div class="ui-g-2">2</div>
<div class="ui-g-2">2</div>
<div class="ui-g-2">2</div>
<div class="ui-g-2">2</div>
<div class="ui-g-2">2</div>
</div>
<div class="ui-g">
<div class="ui-g-3">3</div>
<div class="ui-g-3">3</div>
<div class="ui-g-3">3</div>
<div class="ui-g-3">3</div>
</div>
<div class="ui-g">
<div class="ui-g-4">4</div>
<div class="ui-g-4">4</div>
<div class="ui-g-4">4</div>
</div>
<div class="ui-g">
<div class="ui-g-6">6</div>
<div class="ui-g-6">6</div>
</div>
<div class="ui-g">
<div class="ui-g-12">12</div>
</div>
<div class="ui-g">
<div class="ui-g-4">4</div>
<div class="ui-g-8">8</div>
</div>
<div class="ui-g">
<div class="ui-g-3">3</div>
<div class="ui-g-9">9</div>
</div>
<div class="ui-g">
<div class="ui-g-3">3</div>
<div class="ui-g-5">5</div>
<div class="ui-g-4">4</div>
</div>
<div class="ui-g">
<div class="ui-g-4">4</div>
<div class="ui-g-2">2</div>
<div class="ui-g-2">2</div>
<div class="ui-g-3">3</div>
<div class="ui-g-1">1</div>
</div>
<h3>Responsive</h3>
<div class="ui-g">
<div class="ui-g-12 ui-md-6 ui-lg-3">ui-g-12 ui-md-6 ui-lg-3</div>
<div class="ui-g-12 ui-md-6 ui-lg-3">ui-g-12 ui-md-6 ui-lg-3</div>
<div class="ui-g-12 ui-md-6 ui-lg-3">ui-g-12 ui-md-6 ui-lg-3</div>
<div class="ui-g-12 ui-md-6 ui-lg-3">ui-g-12 ui-md-6 ui-lg-3</div>
</div>
<div class="ui-g">
<div class="ui-g-12 ui-md-6 ui-lg-4">ui-g-12 ui-md-6 ui-lg-4</div>
<div class="ui-g-12 ui-md-6 ui-lg-4">ui-g-12 ui-md-6 ui-lg-4</div>
<div class="ui-g-12 ui-lg-4">ui-g-12 ui-lg-4</div>
</div>
<h3>Nested</h3>
<div class="ui-g">
<div class="ui-g-8 ui-g-nopad">
<div class="ui-g-6">6</div>
<div class="ui-g-6">6</div>
<div class="ui-g-12">12</div>
</div>
<div class="ui-g-4">4</div>
</div>
<h3>Offset</h3>
<div class="ui-g">
<div class="ui-g-12 ui-md-4">ui-g-12 ui-md-4</div>
<div class="ui-g-12 ui-md-4 ui-md-offset-4">ui-g-12 i-md-4 ui-md-offset-4</div>
</div>
<h3>Sample Layout</h3>
<div class="ui-g">
<div class="ui-g-12 ui-md-2">Menu</div>
<div class="ui-g-12 ui-md-10 ui-g-nopad">
<div class="ui-g-12">
Bar
</div>
<div class="ui-g-12 ui-g-nopad">
<div class="ui-g">
<div class="ui-g-12 ui-md-4">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet, orci nec dictum convallis, ligula mauris vestibulum turpis, nec varius tortor quam at diam. Nullam a viverra nibh. In tincidunt tempor lectus quis vulputate. Pellentesque nec dui aliquam, lobortis est in, lobortis ante</div>
<div class="ui-g-12 ui-md-4">Maecenas vel nisi aliquet, vulputate tortor id, laoreet massa. Maecenas mattis tristique bibendum. Suspendisse vel mi dictum, vestibulum lacus quis, pulvinar quam. Proin vulputate, nibh at finibus varius, leo eros lacinia elit, nec blandit odio tellus a justo. Donec nec ex auctor, tristique nulla nec, rutrum sapien.</div>
<div class="ui-g-12 ui-md-4">Proin efficitur in leo eget ornare. Nam vestibulum neque sed velit sagittis sodales. Sed scelerisque hendrerit magna a hendrerit. Cras tempor sem at justo pharetra convallis. Curabitur vel sodales purus. Vestibulum interdum facilisis nulla imperdiet suscipit. Quisque lectus felis, condimentum eget hendrerit sit amet.</div>
</div>
<div class="ui-g">
<div class="ui-g-6 ui-md-3"><img src="assets/showcase/images/demo/galleria/galleria1.jpg" style="width:100%"></div>
<div class="ui-g-6 ui-md-3"><img src="assets/showcase/images/demo/galleria/galleria1.jpg" style="width:100%"></div>
<div class="ui-g-6 ui-md-3"><img src="assets/showcase/images/demo/galleria/galleria1.jpg" style="width:100%"></div>
<div class="ui-g-6 ui-md-3"><img src="assets/showcase/images/demo/galleria/galleria1.jpg" style="width:100%"></div>
</div>
<div class="ui-g">
<div class="ui-g-12 ui-md-6">Phasellus faucibus purus volutpat mauris lacinia sodales. Ut sit amet sapien facilisis, commodo dui non, fringilla tellus. Quisque tempus facilisis nisi sodales finibus. Pellentesque neque orci, ullamcorper vitae ligula quis, dignissim euismod augue.</div>
<div class="ui-g-12 ui-md-6">Fusce ullamcorper congue massa, eget ullamcorper nunc lobortis egestas. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque ultrices dui eget dolor feugiat dapibus. Aliquam pretium leo et egestas luctus. Nunc facilisis gravida tellus.</div>
</div>
</div>
</div>
<div class="ui-g-12">
Footer
</div>
</div>