【问题标题】:Trying to have a grid of card with angular material试图用有角材料的卡片网格
【发布时间】:2015-10-21 22:52:06
【问题描述】:

我一直在尝试使用 angular-material 制作一张卡片网格。所以我使用指令 md-grid-list 和 md-card。但结果很丑陋,我不确定 md-row-heigh (ratio) 是如何工作的,我有文档,但没有说太多。

这是我到目前为止所做的: 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>

我愿意接受任何形式的帮助。

【问题讨论】:

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


    【解决方案1】:

    您可以使用 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

    希望这是你想要的。

    【讨论】:

    • 这样的问题是它没有响应,当屏幕尺寸较小时,卡片应该相互下方。
    • 是的,这个每行有固定数量的图块。处理响应式示例。
    • 您可以通过设置 flex-sm 选项为每个不同的屏幕尺寸设置不同的尺寸或布局。 (答案都在链接页面中)。
    • @ItaloAyres 我有一个问题,如果卡片有不同的高度,在这个例子中是例如卡片里面的文字有不同的大小,我怎样才能把它们放在空白处空格(比如将它们全部对齐到顶部)??如果你不明白请告诉我,我真的需要帮助就像这个例子material.angularjs.org/latest/demo/card
    • @TiagoSousa 我可以用葡萄牙语写吗哈哈? Se você observar nesse exemplo que você mandou, aorganização é feita colocando rows com um único card, dentro de columns。 Que é o contrario do exemplo que eu fiz, onde tem columns dentro de rows。 Isso dá o efeito que você procura.
    【解决方案2】:

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

    <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>
    

    【讨论】:

      猜你喜欢
      • 2015-10-27
      • 2016-03-11
      • 1970-01-01
      • 1970-01-01
      • 2020-12-12
      • 2015-04-23
      • 2015-12-06
      • 1970-01-01
      • 2019-02-17
      相关资源
      最近更新 更多