Styling a md-grid-list

ⅰ亾dé卋堺 提交于 2020-02-22 04:27:04

问题


I am using an Angular Material grid list to display around 500 - 1000 items. I am having some trouble styling it to my liking. Here is what the grid list looks like now:

<md-grid-list md-cols-xs="1" md-cols-sm="2" md-cols-md="4" md-cols-gt-md="6"
              md-row-height="16:9"
              md-gutter="12px" md-gutter-gt-sm="8px">

  <md-grid-tile ng-repeat="orgOrder in vm.orgOrders | filter: query1"
                style="background: #f5f5f5"
                layout-align="center center"
                ng-click="vm.addOrder(orgOrder)">
    <div layout="column">
      <div> {{orgOrder.orderNumber}}</div>
      <!--<div> {{orgOrder.reqExFact | date : 'dd/MM/yyyy'}}</div>-->
    </div>

  </md-grid-tile>
</md-grid-list>

Here is what I would like to do:

  1. My grid titles(items) are a way too big for a single line, how do I make my grid titles fit the data in them? Setting the md-row-height="fit" makes it look like this.
  2. At the moment my grid-list is several 'scrolls' long. I would like to put it into a container and add a scroll to it. Warping my grid-list or grid title in an md-container sets their height to 0.

Let me know if you need to see any more of my code.

here is a jsfiddle similar to my code:https://jsfiddle.net/rakshak/6tjgbb85/

I would like the grid titles(items) to fit the text in them and I would like to wrap a container around the entire grid list and have a overflow scroll bar instead of the entire window scrolling.


回答1:


Setting md-row-height like md-row-height="20px" or md-row-height="30px" seems to address the height issues nicely. Nesting the grid inside of a fixed height div defined something like this:

.tileContainer {display:block;
    width:100%;
    height:100px;}

will give you a scroll bar for the tiles.

I forked your plunker here: https://jsfiddle.net/uegLh6t4/



来源:https://stackoverflow.com/questions/37535181/styling-a-md-grid-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!