angular material 2 md-list odd-even style

主宰稳场 提交于 2019-12-12 03:44:01

问题


Am trying to have a different background for odd/even rows in the md-list. Not sure if this is supported using Angular Material 2 - Md-list component as I don't see any documentation on this.

I believe angular 2 supports this using the ng-class-odd/ng-class-even


回答1:


You should be using below styles in your component

.mat-list >  .mat-list-item:nth-child(2n+1){
  background-color:red;
}
.mat-list >  .mat-list-item:nth-child(2n){
  background-color:blue;
}

LIVE DEMO



来源:https://stackoverflow.com/questions/42351202/angular-material-2-md-list-odd-even-style

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