试图有一个带有角度材料的卡网格

时间:2015-07-30 14:14:17

标签: angularjs material-design grid-layout angular-material

我一直试图使用角度材料制作卡片网格。所以我使用的指令是md-grid-list和md-card。但结果非常难看,而且我不确定md-row-heigh(比率)是如何工作的,我有文档,但它并没有说太多。

这是我到目前为止所做的事情: http://codepen.io/stunaz/pen/qdQwbq,我正在尝试使用响应式网卡,甚至不确定md-grid-list是否合适。

  <md-grid-list md-cols-sm="1" md-cols-md="2" md-cols-gt-md="6" md-row-height="300px" md-gutter="12px" md-gutter-gt-sm="8px">

<md-grid-tile class="gray" ng-repeat="user in users">
  <md-card>
    <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>
</md-grid-tile>

我愿意接受任何帮助。

2 个答案:

答案 0 :(得分:32)

您可以使用Flex Box代替md-grid-list来产生相同的效果。

  <div class='md-padding' layout="row" flex>
     <div layout="row" flex>
        <div class="parent" layout="column" ng-repeat="user in users" flex>
            ... Your content here
        </div>
     </div>
  </div>

使用固定数量的卡连续查看此示例:

http://codepen.io/anon/pen/bdQJxy

响应示例,使用Wrap layout

http://codepen.io/anon/pen/MwzRde

希望这是你想要的。

答案 1 :(得分:1)

使用此HTML标记并更改md卡中的弹性编号以满足您的要求。

<div class='md-padding' layout="row" layout-wrap>
                    <md-card flex="15" ng-repeat ="n in [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]">
                        <img ng-src="http://i2.wp.com/celebsbios.com/wp-content/uploads/2015/12/Halsey-Singer-3.jpg?resize=150%2C150" class="md-card-image" alt="Washed Out">
                        <md-card-title>
                            <md-card-title-text>
                                <span class="md-headline">Action buttons</span>
                            </md-card-title-text>
                        </md-card-title>
                        <md-card-content>
                            <p>
                                The titles of Washed Out's breakthrough song and the first single from Paracosm share the
                                two most important words in Ernest Greene's musical language: feel it. It's a simple request, as well...
                            </p>
                            <p>
                                The titles of Washed Out's breakthrough song and the first single from Paracosm share the
                                two most important words in Ernest Greene's musical language: feel it. It's a simple request, as well...
                            </p>
                            <p>
                                The titles of Washed Out's breakthrough song and the first single from Paracosm share the
                                two most important words in Ernest Greene's musical language: feel it. It's a simple request, as well...
                            </p>
                        </md-card-content>
                        <md-card-actions layout="row" layout-align="end center">
                            <md-button>Action 1</md-button>
                            <md-button>Action 2</md-button>
                        </md-card-actions>
                    </md-card>
                </div>