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.

Grid - 图1

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;

  1. <div class="ui-g">
  2. <div class="ui-g-4">Col1</div>
  3. <div class="ui-g-4">Col2</div>
  4. <div class="ui-g-4">Col3</div>
  5. </div>
  6.  

Col1

Col2

Col3

Multi Line

When the number of columns exceed 12, columns wrap to a new line.

  1. <div class="ui-g">
  2. <div class="ui-g-6">Col1</div>
  3. <div class="ui-g-6">Col2</div>
  4. <div class="ui-g-6">Col3</div>
  5. <div class="ui-g-6">Col4</div>
  6. </div>
  7.  

Col1

Col2

Col3

Col3

Same can also be achieved by having two ui-g containers to semantically define a row.

  1. <div class="ui-g">
  2. <div class="ui-g-6">Col1</div>
  3. <div class="ui-g-6">Col2</div>
  4. </div>
  5. <div class="ui-g">
  6. <div class="ui-g-6">Col3</div>
  7. <div class="ui-g-6">Col4</div>
  8. </div>
  9.  

Col1

Col2

Col3

Col4

Nested

Columns can be nested to create more complex layouts.

  1. <div class="ui-g">
  2. <div class="ui-g-8 ui-g-nopad">
  3. <div class="ui-g-6">6</div>
  4. <div class="ui-g-6">6</div>
  5. <div class="ui-g-12">12</div>
  6. </div>
  7. <div class="ui-g-4">4</div>
  8. </div>
  9.  

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.

  1. <div class="ui-g">
  2. <div class="ui-g-8 ui-g-nopad">
  3. <div class="ui-g-6">6 <br /><br /><br /> Content </div>
  4. <div class="ui-g-6">6</div>
  5. <div class="ui-g-12">12</div>
  6. </div>
  7. <div class="ui-g-4">4</div>
  8. </div>
  9.  

6 Content

6

12

4

Solution is wrapping the internal divs inside a ui-g as well.

  1. <div class="ui-g">
  2. <div class="ui-g-8 ui-g-nopad">
  3. <div class="ui-g">
  4. <div class="ui-g-6">6 <br /><br /><br /> Content </div>
  5. <div class="ui-g-6">6</div>
  6. <div class="ui-g-12">12</div>
  7. </div>
  8. </div>
  9. <div class="ui-g-4">4</div>
  10. </div>
  11.  

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.

PrefixDevicesMedia QueryExample
ui-sm-Small devices like phonesmax-width: 40em (640px)ui-sm-6, ui-sm-4
ui-md-Medium sized devices such as tabletsmin-width: 40.063em (641px)ui-md-2, ui-sm-8
ui-lg-Devices with large screen like desktopsmin-width: 64.063em (1025px)ui-lg-6, ui-sm-12
ui-xl-Big screen monitorsmin-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.

  1. <div class="ui-g">
  2. <div class="ui-g-12 ui-md-6 ui-lg-3">ui-g-12 ui-md-6 ui-lg-3</div>
  3. <div class="ui-g-12 ui-md-6 ui-lg-3">ui-g-12 ui-md-6 ui-lg-3</div>
  4. <div class="ui-g-12 ui-md-6 ui-lg-3">ui-g-12 ui-md-6 ui-lg-3</div>
  5. <div class="ui-g-12 ui-md-6 ui-lg-3">ui-g-12 ui-md-6 ui-lg-3</div>
  6. </div>
  7.  

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.

  1. <div class="ui-g">
  2. <div class="ui-g-12 ui-md-6 ui-lg-4">ui-g-12 ui-md-6 ui-lg-4</div>
  3. <div class="ui-g-12 ui-md-6 ui-lg-4">ui-g-12 ui-md-6 ui-lg-4</div>
  4. <div class="ui-g-12 ui-lg-4">ui-g-12 ui-lg-4</div>
  5. </div>
  6.  

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.

  1. <div class="ui-g">
  2. <div class="ui-g-12 ui-md-4">ui-g-12 ui-md-4</div>
  3. <div class="ui-g-12 ui-md-4 ui-md-offset-4">ui-g-12 i-md-4 ui-md-offset-4</div>
  4. </div>
  5.  

The list of offset classes varying within a range of 1 to 12.

PrefixDevicesMedia QueryExample
ui-g-offset-All devicesAll screensui-g-offset-6, ui-g-offset-4
ui-sm-offset-Small devices like phonesmax-width: 40em (640px)ui-sm-offset-6, ui-sm-offset-4
ui-md-offset-Medium sized devices such as tabletsmin-width: 40.063em (641px)ui-md-offset-6, ui-md-offset-4
ui-lg-offset-Devices with large screen like desktopsmin-width: 64.063em (1025px)ui-lg-offset-6, ui-lg-offset-4
ui-xl-offset-*Big screen monitorsmin-width: 90.063em (1441px)ui-xl-offset-6, ui-xl-offset-4

Source

View on GitHub

  1. <h3 class="first">Basic</h3>
  2. <div class="ui-g">
  3. <div class="ui-g-1">1</div>
  4. <div class="ui-g-1">1</div>
  5. <div class="ui-g-1">1</div>
  6. <div class="ui-g-1">1</div>
  7. <div class="ui-g-1">1</div>
  8. <div class="ui-g-1">1</div>
  9. <div class="ui-g-1">1</div>
  10. <div class="ui-g-1">1</div>
  11. <div class="ui-g-1">1</div>
  12. <div class="ui-g-1">1</div>
  13. <div class="ui-g-1">1</div>
  14. <div class="ui-g-1">1</div>
  15. </div>
  16. <div class="ui-g">
  17. <div class="ui-g-2">2</div>
  18. <div class="ui-g-2">2</div>
  19. <div class="ui-g-2">2</div>
  20. <div class="ui-g-2">2</div>
  21. <div class="ui-g-2">2</div>
  22. <div class="ui-g-2">2</div>
  23. </div>
  24. <div class="ui-g">
  25. <div class="ui-g-3">3</div>
  26. <div class="ui-g-3">3</div>
  27. <div class="ui-g-3">3</div>
  28. <div class="ui-g-3">3</div>
  29. </div>
  30. <div class="ui-g">
  31. <div class="ui-g-4">4</div>
  32. <div class="ui-g-4">4</div>
  33. <div class="ui-g-4">4</div>
  34. </div>
  35. <div class="ui-g">
  36. <div class="ui-g-6">6</div>
  37. <div class="ui-g-6">6</div>
  38. </div>
  39. <div class="ui-g">
  40. <div class="ui-g-12">12</div>
  41. </div>
  42. <div class="ui-g">
  43. <div class="ui-g-4">4</div>
  44. <div class="ui-g-8">8</div>
  45. </div>
  46. <div class="ui-g">
  47. <div class="ui-g-3">3</div>
  48. <div class="ui-g-9">9</div>
  49. </div>
  50. <div class="ui-g">
  51. <div class="ui-g-3">3</div>
  52. <div class="ui-g-5">5</div>
  53. <div class="ui-g-4">4</div>
  54. </div>
  55. <div class="ui-g">
  56. <div class="ui-g-4">4</div>
  57. <div class="ui-g-2">2</div>
  58. <div class="ui-g-2">2</div>
  59. <div class="ui-g-3">3</div>
  60. <div class="ui-g-1">1</div>
  61. </div>
  62. <h3>Responsive</h3>
  63. <div class="ui-g">
  64. <div class="ui-g-12 ui-md-6 ui-lg-3">ui-g-12 ui-md-6 ui-lg-3</div>
  65. <div class="ui-g-12 ui-md-6 ui-lg-3">ui-g-12 ui-md-6 ui-lg-3</div>
  66. <div class="ui-g-12 ui-md-6 ui-lg-3">ui-g-12 ui-md-6 ui-lg-3</div>
  67. <div class="ui-g-12 ui-md-6 ui-lg-3">ui-g-12 ui-md-6 ui-lg-3</div>
  68. </div>
  69. <div class="ui-g">
  70. <div class="ui-g-12 ui-md-6 ui-lg-4">ui-g-12 ui-md-6 ui-lg-4</div>
  71. <div class="ui-g-12 ui-md-6 ui-lg-4">ui-g-12 ui-md-6 ui-lg-4</div>
  72. <div class="ui-g-12 ui-lg-4">ui-g-12 ui-lg-4</div>
  73. </div>
  74. <h3>Nested</h3>
  75. <div class="ui-g">
  76. <div class="ui-g-8 ui-g-nopad">
  77. <div class="ui-g-6">6</div>
  78. <div class="ui-g-6">6</div>
  79. <div class="ui-g-12">12</div>
  80. </div>
  81. <div class="ui-g-4">4</div>
  82. </div>
  83. <h3>Offset</h3>
  84. <div class="ui-g">
  85. <div class="ui-g-12 ui-md-4">ui-g-12 ui-md-4</div>
  86. <div class="ui-g-12 ui-md-4 ui-md-offset-4">ui-g-12 i-md-4 ui-md-offset-4</div>
  87. </div>
  88. <h3>Sample Layout</h3>
  89. <div class="ui-g">
  90. <div class="ui-g-12 ui-md-2">Menu</div>
  91. <div class="ui-g-12 ui-md-10 ui-g-nopad">
  92. <div class="ui-g-12">
  93. Bar
  94. </div>
  95. <div class="ui-g-12 ui-g-nopad">
  96. <div class="ui-g">
  97. <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>
  98. <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>
  99. <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>
  100. </div>
  101. <div class="ui-g">
  102. <div class="ui-g-6 ui-md-3"><img src="assets/showcase/images/demo/galleria/galleria1.jpg" style="width:100%"></div>
  103. <div class="ui-g-6 ui-md-3"><img src="assets/showcase/images/demo/galleria/galleria1.jpg" style="width:100%"></div>
  104. <div class="ui-g-6 ui-md-3"><img src="assets/showcase/images/demo/galleria/galleria1.jpg" style="width:100%"></div>
  105. <div class="ui-g-6 ui-md-3"><img src="assets/showcase/images/demo/galleria/galleria1.jpg" style="width:100%"></div>
  106. </div>
  107. <div class="ui-g">
  108. <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>
  109. <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>
  110. </div>
  111. </div>
  112. </div>
  113. <div class="ui-g-12">
  114. Footer
  115. </div>
  116. </div>
  117.