Flex GridFlex Grid CSS is a lightweight flex based responsive layout utility optimized for mobile phones, tablets and desktops. Flex Grid CSS is not included in PrimeNG as it is provided by PrimeFlex, a shared grid library between PrimeFaces, PrimeNG and PrimeReact projects.

FlexGrid - 图1

Documentation” class=”ng-tns-c2-1

Getting Started

PrimeFlex is available at npm, if you have an existing application run the following command to download it to your project.

  1. npm install primeflex --save
  2.  

Then add the primeflex.css to your application, example below uses styles configuration of an Angular CLI project.

  1. "styles": [
  2. "node_modules/primeflex/primeflex.css"
  3. ],
  4.  

A basic grid is defined by giving a container "p-grid" class and children the ".p-col" class. Children of the grid will have the same width and scale according to the width of the parent.

  1. <div class="p-grid">
  2. <div class="p-col">1</div>
  3. <div class="p-col">2</div>
  4. <div class="p-col">3</div>
  5. </div>
  6.  

1

2

3

Direction

Default direction is "row" and p-dir-* class at the container defines the other possible directions which can be row reverse, column and column reverse.

  1. <!-- Row Reverse -->
  2. <div class="p-grid p-dir-rev">
  3. <div class="p-col">1</div>
  4. <div class="p-col">2</div>
  5. <div class="p-col">3</div>
  6. </div>
  7. <!-- Column -->
  8. <div class="p-grid p-dir-col">
  9. <div class="p-col">1</div>
  10. <div class="p-col">2</div>
  11. <div class="p-col">3</div>
  12. </div>
  13. <!-- Column Reverse -->
  14. <div class="p-grid p-dir-col-rev">
  15. <div class="p-col">1</div>
  16. <div class="p-col">2</div>
  17. <div class="p-col">3</div>
  18. </div>
  19.  

1

2

3

1

2

3

1

2

3

12 Column Grid

FlexGrid includes a 12 column based layout utility where width of a column is defined with the p-col-{number} style class. Columns with prefined widths can be used with columns with auto width (p-col) as well.

In the first example below, first column covers the 4 units out of 12 and the rest of the columns share the remaining space whereas in the second example, all three columns have explicit units.

  1. <div class="p-grid">
  2. <div class="p-col-4">4</div>
  3. <div class="p-col">1 </div>
  4. <div class="p-col">1 </div>
  5. <div class="p-col">1 </div>
  6. <div class="p-col">1 </div>
  7. <div class="p-col">1 </div>
  8. <div class="p-col">1 </div>
  9. <div class="p-col">1 </div>
  10. <div class="p-col">1 </div>
  11. </div>
  12. <div class="p-grid">
  13. <div class="p-col-2">2</div>
  14. <div class="p-col-6">6</div>
  15. <div class="p-col-4">4</div>
  16. </div>
  17.  

4

1

1

1

1

1

1

1

1

2

6

4

Multi Line

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

  1. <div class="p-grid">
  2. <div class="p-col-6">6</div>
  3. <div class="p-col-6">6</div>
  4. <div class="p-col-6">6</div>
  5. <div class="p-col-6">6</div>
  6. </div>
  7.  

6

6

6

6

Fixed Width Column

A column can have a fixed width while siblings having auto width. Apply "p-col-fixed" class to fix a column width.

  1. <div class="p-grid">
  2. <div class="p-col-fixed" style="width:100px">Fixed</div>
  3. <div class="p-col">Auto</div>
  4. </div>
  5.  

100px

auto

Responsive

Responsive layout is achieved by applying breakpoint specific classes to the columns whereas p-col-* define the default behavior for mobile devices with small screens. Four screen sizes are supported with different breakpoints.

PrefixDevicesMedia QueryExample
p-sm-Small devicesmin-width: 576pxp-sm-6, p-sm-4
p-md-Medium sized devices such as tabletsmin-width: 768pxp-md-2, p-md-8
p-lg-Devices with large screen like desktopsmin-width: 992pxp-lg-6, p-lg-12
p-xl-Big screen monitorsmin-width: 1200pxp-xl-2, p-xl-10

In example below, large screens display 4 columns, medium screens display 2 columns in 2 rows and finally on small devices, columns are stacked.

  1. <div class="p-grid">
  2. <div class="p-col-12 p-md-6 p-lg-3">A</div>
  3. <div class="p-col-12 p-md-6 p-lg-3">B</div>
  4. <div class="p-col-12 p-md-6 p-lg-3">C</div>
  5. <div class="p-col-12 p-md-6 p-lg-3">D</div>
  6. </div>
  7.  

p-col-12 p-md-6 p-lg-3

p-col-12 p-md-6 p-lg-3

p-col-12 p-md-6 p-lg-3

p-col-12 p-md-6 p-lg-3

Horizontal Alignment

p-justify-* classes are used on the container element to define the alignment along the main axis.

ClassDescription
p-justify-start (default)Items are packed toward the start line
p-justify-endItems are packed toward to end line
p-justify-centerItems are centered along the line
p-justify-betweenItems are evenly distributed in the line; first item is on the start line, last item on the end line
p-justify-aroundItems are evenly distributed in the line with equal space around them.
p-justify-evenItems are distributed so that the spacing between any two items (and the space to the edges) is equal.
  1. <div class="p-grid p-justify-between">
  2. <div class="p-col-2">2</div>
  3. <div class="p-col-1">1</div>
  4. <div class="p-col-4">4</div>
  5. </div>
  6.  

2

1

4

Vertical Alignment

p-align-* classes are used on the container element to define the alignment along the cross axis.

ClassDescription
p-align-stretch (default) stretch to fill the container.
p-align-startCross-start margin edge of the items is placed on the cross-start line
p-align-endCross-end margin edge of the items is placed on the cross-end line
p-align-centerItems are centered in the cross-axis
p-align-baselineItems are aligned such as their baselines align
  1. <div class="p-grid p-align-center">
  2. <div class="p-col">4</div>
  3. <div class="p-col">4</div>
  4. <div class="p-col">4</div>
  5. </div>
  6.  

4

4

4

Vertical alignment can also be defined at column level with the p-col-align-* classes.

ClassDescription
p-col-align-stretchStretch to fill the container.
p-col-align-startCross-start margin edge of the items is placed on the cross-start line
p-col-align-endCross-end margin edge of the items is placed on the cross-end line
p-col-align-centerItems are centered in the cross-axis
p-col-align-baselineItems are aligned such as their baselines align
  1. <div class="p-grid">
  2. <div class="p-col p-col-align-start">4</div>
  3. <div class="p-col p-col-align-center">4</div>
  4. <div class="p-col p-col-align-end">4</div>
  5. </div>
  6.  

4

4

4

Offset

Offset classes allow defining a left margin on a column to avoid adding empty columns for spacing.

  1. <div class="p-grid">
  2. <div class="p-col-6 p-offset-3">6</div>
  3. </div>
  4. <div class="p-grid">
  5. <div class="p-col-4">4 </div>
  6. <div class="p-col-4 p-offset-4">4</div>
  7. </div>
  8.  

6

4

4

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

PrefixDevicesMedia QueryExample
p-col-offset-All devicesAll screensp-col-offset-6, p-col-offset-4
p-sm-offset-Small devicesmin-width: 576pxp-sm-offset-6, p-sm-offset-4
p-md-offset-Medium sized devices such as tabletsmin-width: 768pxp-md-offset-6, p-md-offset-4
p-lg-offset-Devices with large screen like desktopsmin-width: 992pxp-lg-offset-6, p-lg-offset-4
p-xl-offset-*Big screen monitorsmin-width: 1200pxp-xl-offset-6, p-xl-offset-4

Nested

Columns can be nested to create more complex layouts.

  1. <div class="p-grid">
  2. <div class="p-col-8">
  3. <div class="p-grid">
  4. <div class="p-col-6">
  5. 6
  6. </div>
  7. <div class="p-col-6">
  8. 6
  9. </div>
  10. <div class="p-col-12">
  11. 12
  12. </div>
  13. </div>
  14. </div>
  15. <div class="p-col-4">
  16. 4
  17. </div>
  18. </div>
  19.  

6

6

12

4

Gutter

A .5 em padding is applied to each column along with negative margins on the container element, in case you'd like to remove these gutters, apply .p-nogutter class to the container. Gutters can also be removed on an ndividual columns with the same class name.

  1. <div class="p-grid p-nogutter">
  2. <div class="p-col">1</div>
  3. <div class="p-col p-nogutter">2</div>
  4. <div class="p-col">3</div>
  5. </div>
  6.  

Customization

PrimeFlex allows customization of breakpoints and gutters via SASS variables, visit the PrimeFlex repository to get access to the primeflex.scss file to build your own customized Grid.

Source” class=”ng-tns-c2-1

View on GitHub

  1. <h3 class="first">Basic</h3>
  2. <div class="p-grid">
  3. <div class="p-col">
  4. <div class="box">1</div>
  5. </div>
  6. <div class="p-col">
  7. <div class="box">2</div>
  8. </div>
  9. <div class="p-col">
  10. <div class="box">3</div>
  11. </div>
  12. </div>
  13. <h3>Dynamic</h3>
  14. <button pButton type="button" icon="pi pi-plus" title="Add Column" (click)="addColumn()" [disabled]="columns.length === 20" style="margin-right: .5em"></button>
  15. <button pButton type="button" icon="pi pi-minus" title="Remove Column" (click)="removeColumn()"[disabled]="columns.length === 1"></button>
  16. <div class="p-grid" style="margin-top: .5em">
  17. <div class="p-col" *ngFor="let col of columns; let i=index" [@animation]="'visible'">
  18. <div class="box">{{i + 1}}</div>
  19. </div>
  20. </div>
  21. <h3>Reverse Direction</h3>
  22. <div class="p-grid p-dir-rev">
  23. <div class="p-col">
  24. <div class="box">1</div>
  25. </div>
  26. <div class="p-col">
  27. <div class="box">2</div>
  28. </div>
  29. <div class="p-col">
  30. <div class="box">3</div>
  31. </div>
  32. </div>
  33. <h3>Column Direction</h3>
  34. <div class="p-grid p-dir-col">
  35. <div class="p-col">
  36. <div class="box">1</div>
  37. </div>
  38. <div class="p-col">
  39. <div class="box">2</div>
  40. </div>
  41. <div class="p-col">
  42. <div class="box">3</div>
  43. </div>
  44. </div>
  45. <h3>Reverse Column Direction</h3>
  46. <div class="p-grid p-dir-col-rev">
  47. <div class="p-col">
  48. <div class="box">1</div>
  49. </div>
  50. <div class="p-col">
  51. <div class="box">2</div>
  52. </div>
  53. <div class="p-col">
  54. <div class="box">3</div>
  55. </div>
  56. </div>
  57. <h3>12 Column Grid</h3>
  58. <div class="p-grid">
  59. <div class="p-col-4">
  60. <div class="box">4</div>
  61. </div>
  62. <div class="p-col">
  63. <div class="box">1</div>
  64. </div>
  65. <div class="p-col">
  66. <div class="box">1</div>
  67. </div>
  68. <div class="p-col">
  69. <div class="box">1</div>
  70. </div>
  71. <div class="p-col">
  72. <div class="box">1</div>
  73. </div>
  74. <div class="p-col">
  75. <div class="box">1</div>
  76. </div>
  77. <div class="p-col">
  78. <div class="box">1</div>
  79. </div>
  80. <div class="p-col">
  81. <div class="box">1</div>
  82. </div>
  83. <div class="p-col">
  84. <div class="box">1</div>
  85. </div>
  86. </div>
  87. <div class="p-grid">
  88. <div class="p-col-2">
  89. <div class="box">2</div>
  90. </div>
  91. <div class="p-col-6">
  92. <div class="box">6</div>
  93. </div>
  94. <div class="p-col-4">
  95. <div class="box">4</div>
  96. </div>
  97. </div>
  98. <div class="p-grid">
  99. <div class="p-col-8">
  100. <div class="box">8</div>
  101. </div>
  102. <div class="p-col-2">
  103. <div class="box">2</div>
  104. </div>
  105. <div class="p-col-2">
  106. <div class="box">2</div>
  107. </div>
  108. </div>
  109. <h3>MultiLine</h3>
  110. <div class="p-grid">
  111. <div class="p-col-6">
  112. <div class="box">6</div>
  113. </div>
  114. <div class="p-col-6">
  115. <div class="box">6</div>
  116. </div>
  117. <div class="p-col-6">
  118. <div class="box">6</div>
  119. </div>
  120. <div class="p-col-6">
  121. <div class="box">6</div>
  122. </div>
  123. </div>
  124. <h3>Fixed Width Column</h3>
  125. <div class="p-grid">
  126. <div class="p-col-fixed" style="width:100px">
  127. <div class="box">100px</div>
  128. </div>
  129. <div class="p-col">
  130. <div class="box">auto</div>
  131. </div>
  132. </div>
  133. <h3>Responsive</h3>
  134. <div class="p-grid">
  135. <div class="p-col-12 p-md-6 p-lg-3">
  136. <div class="box">p-col-12 p-md-6 p-lg-3</div>
  137. </div>
  138. <div class="p-col-12 p-md-6 p-lg-3">
  139. <div class="box">p-col-12 p-md-6 p-lg-3</div>
  140. </div>
  141. <div class="p-col-12 p-md-6 p-lg-3">
  142. <div class="box">p-col-12 p-md-6 p-lg-3</div>
  143. </div>
  144. <div class="p-col-12 p-md-6 p-lg-3">
  145. <div class="box">p-col-12 p-md-6 p-lg-3</div>
  146. </div>
  147. </div>
  148. <h3>Horizontal Alignment - Start</h3>
  149. <div class="p-grid p-justify-start">
  150. <div class="p-col-2">
  151. <div class="box">2</div>
  152. </div>
  153. <div class="p-col-1">
  154. <div class="box">1</div>
  155. </div>
  156. <div class="p-col-4">
  157. <div class="box">4</div>
  158. </div>
  159. </div>
  160. <h3>Horizontal Alignment - End</h3>
  161. <div class="p-grid p-justify-end">
  162. <div class="p-col-2">
  163. <div class="box">2</div>
  164. </div>
  165. <div class="p-col-1">
  166. <div class="box">1</div>
  167. </div>
  168. <div class="p-col-4">
  169. <div class="box">4</div>
  170. </div>
  171. </div>
  172. <h3>Horizontal Alignment - Center</h3>
  173. <div class="p-grid p-justify-center">
  174. <div class="p-col-2">
  175. <div class="box">2</div>
  176. </div>
  177. <div class="p-col-1">
  178. <div class="box">1</div>
  179. </div>
  180. <div class="p-col-4">
  181. <div class="box">4</div>
  182. </div>
  183. </div>
  184. <h3>Horizontal Alignment - Between</h3>
  185. <div class="p-grid p-justify-between">
  186. <div class="p-col-2">
  187. <div class="box">2</div>
  188. </div>
  189. <div class="p-col-1">
  190. <div class="box">1</div>
  191. </div>
  192. <div class="p-col-4">
  193. <div class="box">4</div>
  194. </div>
  195. </div>
  196. <h3>Horizontal Alignment - Around</h3>
  197. <div class="p-grid p-justify-around">
  198. <div class="p-col-2">
  199. <div class="box">2</div>
  200. </div>
  201. <div class="p-col-1">
  202. <div class="box">1</div>
  203. </div>
  204. <div class="p-col-4">
  205. <div class="box">4</div>
  206. </div>
  207. </div>
  208. <h3>Horizontal Alignment - Even</h3>
  209. <div class="p-grid p-justify-even">
  210. <div class="p-col-2">
  211. <div class="box">2</div>
  212. </div>
  213. <div class="p-col-1">
  214. <div class="box">1</div>
  215. </div>
  216. <div class="p-col-4">
  217. <div class="box">4</div>
  218. </div>
  219. </div>
  220. <h3>Vertical Alignment - Start</h3>
  221. <div class="p-grid p-align-start vertical-container">
  222. <div class="p-col">
  223. <div class="box">4</div>
  224. </div>
  225. <div class="p-col">
  226. <div class="box">4</div>
  227. </div>
  228. <div class="p-col">
  229. <div class="box">4</div>
  230. </div>
  231. </div>
  232. <h3>Vertical Alignment - End</h3>
  233. <div class="p-grid p-align-end vertical-container">
  234. <div class="p-col">
  235. <div class="box">4</div>
  236. </div>
  237. <div class="p-col">
  238. <div class="box">4</div>
  239. </div>
  240. <div class="p-col">
  241. <div class="box">4</div>
  242. </div>
  243. </div>
  244. <h3>Vertical Alignment - Center</h3>
  245. <div class="p-grid p-align-center vertical-container">
  246. <div class="p-col">
  247. <div class="box">4</div>
  248. </div>
  249. <div class="p-col">
  250. <div class="box">4</div>
  251. </div>
  252. <div class="p-col">
  253. <div class="box">4</div>
  254. </div>
  255. </div>
  256. <h3>Vertical Alignment - Stretch</h3>
  257. <div class="p-grid p-align-stretch vertical-container">
  258. <div class="p-col">
  259. <div class="box box box-stretched">4</div>
  260. </div>
  261. <div class="p-col">
  262. <div class="box box box-stretched">4</div>
  263. </div>
  264. <div class="p-col">
  265. <div class="box box box-stretched">4</div>
  266. </div>
  267. </div>
  268. <h3>Vertical Alignment - Per Column</h3>
  269. <div class="p-grid vertical-container">
  270. <div class="p-col p-col-align-start">
  271. <div class="box">4</div>
  272. </div>
  273. <div class="p-col p-col-align-center">
  274. <div class="box">4</div>
  275. </div>
  276. <div class="p-col p-col-align-end">
  277. <div class="box">4</div>
  278. </div>
  279. </div>
  280. <h3>Offset</h3>
  281. <div class="p-grid">
  282. <div class="p-col-6 p-offset-3">
  283. <div class="box">6</div>
  284. </div>
  285. </div>
  286. <div class="p-grid">
  287. <div class="p-col-4">
  288. <div class="box">4</div>
  289. </div>
  290. <div class="p-col-4 p-offset-4">
  291. <div class="box">4</div>
  292. </div>
  293. </div>
  294. <h3>Nested</h3>
  295. <div class="p-grid nested-grid">
  296. <div class="p-col-8">
  297. <div class="p-grid">
  298. <div class="p-col-6">
  299. <div class="box">6</div>
  300. </div>
  301. <div class="p-col-6">
  302. <div class="box">6</div>
  303. </div>
  304. <div class="p-col-12">
  305. <div class="box">12</div>
  306. </div>
  307. </div>
  308. </div>
  309. <div class="p-col-4">
  310. <div class="box box-stretched">4</div>
  311. </div>
  312. </div>
  313. <h3>Panel Integration</h3>
  314. <div class="p-grid">
  315. <div class="p-col">
  316. <p-panel header="Godfather">
  317. The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
  318. His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
  319. Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family,
  320. kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
  321. </p-panel>
  322. </div>
  323. <div class="p-col">
  324. <p-panel header="Godfather">
  325. The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
  326. His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
  327. Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family,
  328. kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
  329. </p-panel>
  330. </div>
  331. <div class="p-col">
  332. <p-panel header="Godfather">
  333. The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
  334. His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
  335. Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family,
  336. kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
  337. </p-panel>
  338. </div>
  339. </div>
  340. <h3>Sample Layout</h3>
  341. <div class="p-grid sample-layout">
  342. <div class="p-col-12 p-md-2">
  343. Menu
  344. </div>
  345. <div class="p-col-12 p-md-10 p-col-nogutter">
  346. <div class="p-col-12 p-col-nogutter">
  347. Top Bar
  348. </div>
  349. <div class="p-col-12">
  350. <div class="p-grid">
  351. <div class="p-col-12 p-md-4">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet, orci nec
  352. dictum convallis, ligula mauris vestibulum turpis, nec varius tortor quam at diam. Nullam a viverra nibh.
  353. In tincidunt tempor lectus quis vulputate. Pellentesque nec dui aliquam, lobortis est in, lobortis ante</div>
  354. <div class="p-col-12 p-md-4">Maecenas vel nisi aliquet, vulputate tortor id, laoreet massa. Maecenas mattis
  355. tristique bibendum. Suspendisse vel mi dictum, vestibulum lacus quis, pulvinar quam. Proin vulputate, nibh
  356. at finibus varius, leo eros lacinia elit, nec blandit odio tellus a justo. Donec nec ex auctor, tristique
  357. nulla nec, rutrum sapien.</div>
  358. <div class="p-col-12 p-md-4">Proin efficitur in leo eget ornare. Nam vestibulum neque sed velit sagittis
  359. sodales. Sed scelerisque hendrerit magna a hendrerit. Cras tempor sem at justo pharetra convallis.
  360. Curabitur vel sodales purus. Vestibulum interdum facilisis nulla imperdiet suscipit. Quisque lectus felis,
  361. condimentum eget hendrerit sit amet.</div>
  362. <div class="p-col-6 p-md-3"><img src="assets/showcase/images/demo/galleria/galleria1.jpg" style="width:100%"></div>
  363. <div class="p-col-6 p-md-3"><img src="assets/showcase/images/demo/galleria/galleria2.jpg" style="width:100%"></div>
  364. <div class="p-col-6 p-md-3"><img src="assets/showcase/images/demo/galleria/galleria3.jpg" style="width:100%"></div>
  365. <div class="p-col-6 p-md-3"><img src="assets/showcase/images/demo/galleria/galleria4.jpg" style="width:100%"></div>
  366. <div class="p-col-12 p-md-6">Phasellus faucibus purus volutpat mauris lacinia sodales. Ut sit amet sapien
  367. facilisis, commodo dui non, fringilla tellus. Quisque tempus facilisis nisi sodales finibus. Pellentesque
  368. neque orci, ullamcorper vitae ligula quis, dignissim euismod augue.</div>
  369. <div class="p-col-12 p-md-6">Fusce ullamcorper congue massa, eget ullamcorper nunc lobortis egestas. Lorem
  370. ipsum dolor sit amet, consectetur adipiscing elit. Quisque ultrices dui eget dolor feugiat dapibus. Aliquam
  371. pretium leo et egestas luctus. Nunc facilisis gravida tellus.</div>
  372. </div>
  373. </div>
  374. </div>
  375. <div class="p-col-12">
  376. Footer
  377. </div>
  378. </div>
  379.  
  1. import {Component,ViewEncapsulation} from '@angular/core';
  2. import {trigger,state,style,transition,animate,AnimationEvent} from '@angular/animations';
  3. @Component ({
  4. styles:[`
  5. .box,
  6. .sample-layout > div {
  7. background-color: #cce4f7;
  8. text-align: center;
  9. padding-top: 1em;
  10. padding-bottom: 1em;
  11. border-radius: 4px;
  12. }
  13. .box-stretched {
  14. height: 100%;
  15. }
  16. .sample-layout {
  17. margin: 0;
  18. }
  19. .sample-layout > div {
  20. border: 1px solid #ffffff;
  21. }
  22. .vertical-container {
  23. margin: 0;
  24. height: 200px;
  25. background: #efefef;
  26. border-radius: 4px;
  27. }
  28. .nested-grid .p-col-4 {
  29. padding-bottom: 1em;
  30. }
  31. `],
  32. templateUrl: './flexgriddemo.html',
  33. animations: [
  34. trigger('animation', [
  35. state('visible', style({
  36. transform: 'translateX(0)',
  37. opacity: 1
  38. })),
  39. transition('void => *', [
  40. style({transform: 'translateX(50%)', opacity: 0}),
  41. animate('300ms ease-out')
  42. ]),
  43. transition('* => void', [
  44. animate(('250ms ease-in'), style({
  45. height: 0,
  46. opacity: 0,
  47. transform: 'translateX(50%)'
  48. }))
  49. ])
  50. ])
  51. ],
  52. encapsulation: ViewEncapsulation.None
  53. })
  54. export class FlexGridDemo {
  55. columns: number[];
  56. ngOnInit() {
  57. this.columns = [0, 1, 2, 3, 4, 5];
  58. }
  59. addColumn() {
  60. this.columns.push(this.columns.length);
  61. }
  62. removeColumn() {
  63. this.columns.splice(-1, 1);
  64. }
  65. }
  66.