如何使用角度材料创建卡片网格? [英] how do i create a grid of cards with angular material?

查看:107
本文介绍了如何使用角度材料创建卡片网格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用ng-repeat创建每行三张牌的网格。我有一个附加到范围的正常javascript对象数组。下面的代码将为每张卡片创建一个新行。

I am trying to create a grid of three cards per row using ng-repeat. I have a normal array of javascript objects attached to the scope. The code below will create a fresh row for every card.

<div layout="row" ng-repeat='post in posts' layout-fill="" layout-align="">
<md-card>
  <md-card-content>
    <h2 class="md-title">{{post.title}}</h2>
    <p>
      {{post.summary}}
    </p>
  </md-card-content>
  <div class="md-actions" layout="row" layout-align="end center">
    <md-button>View More</md-button>
  </div>
</md-card>
<br>

如何迭代我的阵列并以三行显示卡片?我查看了这篇文章这篇文章,但我看不出它们如何适用于有角物质

How can I iterate over my array and display the cards in rows of three? I looked at this post and this post but I do not see how they apply to angular material

推荐答案

我创建了类似于你可能想要的东西。 md-card 包含在 div 中,其中 layout-wrap 。 div是在阅读后动态生成的。

I have created something similar to what you may want. The md-card is wrapped within a div having layout-wrap. The divs are dynamically generated after reading.

以下是代码:

<div class='md-padding' layout="row" layout-wrap>
    <md-card style="width: 350px;" ng-repeat="user in users">
      <img src="http://placehold.it/150x150" class="md-card-image" alt="user avatar">
      <md-card-content>
        <h2>{{user}}</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</p>
      </md-card-content>
      <div class="md-actions" layout="row" layout-align="end center">
        <md-button>Save</md-button>
        <md-button>View</md-button>
      </div>
    </md-card>
  </div>

可以使用内联样式调整卡片宽度,希望它有所帮助。

The cards width can be adjusted with inline styling, hope it helps.

这篇关于如何使用角度材料创建卡片网格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆