Amp-List with Flex CSS and Amp-Mustache does not work

1.1k Views Asked by At

I'm totally at a loss as to how to apply the flex css to amp-list. I'd like all child items to be evenly spaced in the horizontal with spaces between the items.

When I remove float:left; from the child item, all I get is a column, not rows.

It seems that flex is not applied to the children.

Is it possible to do this? If you can, I'd love the help.

CSS:

.container-flex {
    display:flex;
    flex-flow:row wrap;
    justify-content: space-around;
    display:-webkit-box;display:-ms-flexbox;display:flex;
    ms-flex-wrap:wrap;flex-wrap:wrap;
    -webkit-box-pack:justify;-ms-flex-pack:justify;
    justify-content:space-between 
}
.item-flex {
    float:left;
    min-width:200px;
    min-height:350px;
    flex-basis:auto;
    flex-grow:1
}
.mb2 { margin-bottom:2rem;}
.mx-auto{ margin-left:auto;margin-right:auto;}

AMP-LIST:

<amp-list class="container-flex" [src]="json.src" src="json.src" height="2500" width="auto" layout="fixed-height">
    <template type="amp-mustache">
    <div class="item-flex left mb2 mx-auto">
        ...content...
    </div>
    </template>
</amp-list>
2

There are 2 best solutions below

0
On
.container-flex > div

its applied for inner <div role="list" as parent for item-flex

0
On

Try to change your json. Collect your flex item data in one group in your json resource. Example:

{
  "items":[
      {
         "flex-item-group":[
             { "your-data": "value" },
             { "your-data-2" : "value 2" }
          ]
      }
  ]
}

Then on your html, apply this:

<amp-list class="container-flex" [src]="json.src" src="json.src" height="2500" width="auto" layout="fixed-height">
<template type="amp-mustache">
<div class="item-flex left mb2 mx-auto">
   {{#flex-item-group}}
    ...content...
   {{/flex-item-group}}
</div>
</template>