Trying to have a grid of card with angular material

后端 未结 2 730
时光取名叫无心
时光取名叫无心 2020-12-03 07:12

I have been trying to have a grid of card using angular-material. So I am using the directives md-grid-list and md-card. but the result is pretty ugly, and I am not sure to

相关标签:
2条回答
  • 2020-12-03 08:05

    You could use Flex Box instead of md-grid-list to have the same effect.

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

    Take a look at this Example with fixed number of cards in a row:

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

    And a responsive example, using Wrap layout

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

    Hope this is what you wanted.

    0 讨论(0)
  • 2020-12-03 08:07

    Use this HTML markup and change flex number in md-card to fulfill your requirement.

    <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>
    
    0 讨论(0)
提交回复
热议问题