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

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

问题描述

我正在尝试为 md 列表中的奇数/偶数行设置不同的背景.不确定这是否支持使用 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;
}

现场演示

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

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