角材2 md-list奇偶样式 [英] angular material 2 md-list odd-even style

查看:80
本文介绍了角材2 md-list奇偶样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Am试图为md-list中的奇数/偶数行设置不同的背景. 不确定使用Angular Material 2-Md-list组件是否支持此功能,因为我没有看到任何文档.

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.

我相信angular 2可以使用ng-class-odd/ng-class-even

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

推荐答案

您应该在组件中使用以下样式

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

这篇关于角材2 md-list奇偶样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆