flex grid not working for p-col-# primeng Angular 5

Viewed 20201

i am using primeNG for angular

https://www.primefaces.org/primeng/#/flexgrid

when i am trying this

<div class="p-grid">
<div class="p-col-6">
<div class="box">6 </div>
</div>
<div class="p-col-6">
<div class="box">6 </div>
</div>

</div>

the boxs are on top of each other and not next to each other i run

npm install primeflex --save

and added

"node_modules/primeflex/primeflex.css"

to angular.json

seems to be some thing related to the primeflex.css

the p-col class is working fine but the p-col-# (p-col-1 , p-col-2 etc ) are not working as excpected

this is the values for the p-col

-webkit-box-flex: 1;
-ms-flex-positive: 1;
flex-grow: 1;
-ms-flex-preferred-size: 0;
flex-basis: 0;
padding: 0.5em;

this is the values for the p-col-#

-webkit-box-flex: 0;
-ms-flex: 0 0 auto;
flex: 0 0 auto;
padding: 0.5em;

if for exmample i change the padding of the p-col-# to 0 then it is working but i don't have padding.. (i tried to change the p-col-# to the same values as the p-col and it is not working )

any ideas ?

Thanks Rahav

6 Answers

It is work in my Angular6 project.

  1. install PrimeNG and PrimeFlex

    npm install primeng --save
    npm install primeflex --save
    
  2. add style to angular.json

    "./node_modules/primeng/resources/primeng.css",
    "./node_modules/primeflex/primeflex.css"
    

app.component.html

<div class="p-grid">
    <div class="p-col">1</div>
    <div class="p-col">2</div>
    <div class="p-col">3</div>
</div>

use "grid" instead of "p-grid", there is class name change in lib files.

I had the same problem in Angular 7 with PrimeNG PrimeFlex.

Added the following to the styles.css file to fix it.

 * {
  -webkit-box-sizing: border-box;
}

For PrimeNG version 3 or more use "grid" instead of "p-grid" and "col" instead of "p-col".

No need to update any library.

Note - Stack - Angular 12 and PrimeNG 3.X.X

  1. install PrimeNG and PrimeFlex

    npm install primeng --save
    
    npm i primeflex@2.0.0 --save
    
  2. add style to angular.json

    "./node_modules/primeng/resources/primeng.css",
    
    "./node_modules/primeflex/primeflex.css"
    

Please use primeflex 2.0.0 , Latest version (3+) have some issues.

In addition to the other answers about removing the p- from grid and col in PrimeNG PrimeFlex version 3, I had to go through the source code to find that the breakpoints have also changed to a new syntax.

Old: p-sm-6 New: sm:col-8

Example:

<div class="grid">
  <div class="col-12 sm:col-10 md:col-8 lg:col-6 xl:col-4">
    <!-- Column content -->
  <div>
</div>
Related