【发布时间】:2020-05-18 05:32:13
【问题描述】:
我想更改具有特定类的垫子扩展面板的边框颜色和宽度。
html
<div>
<mat-accordion>
<mat-expansion-panel *ngFor="let item of itemList; let i=index"
[hideToggle]="true"
[class.selected]="item.selected">
<mat-expansion-panel-header>
<mat-panel-title>{{item.header}}</mat-panel-title>
</mat-expansion-panel-header>
{{item.content}}
</mat-expansion-panel>
</mat-accordion>
</div>
ts
import { Component } from '@angular/core';
interface Item {
header: string;
content: string;
selected: boolean;
}
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
public itemList: Item[] = [
{
header: 'Item1',
content: 'This is item1.',
selected: false,
},
{
header: 'Item2',
content: 'This is item2.',
selected: true,
}
];
}
css
.selected {
border-width: 2px;
border-color: red;
}
我想将Item2 的边框颜色设置为红色,宽度为 2px。但是上面的例子不起作用。
我该如何解决?
【问题讨论】:
标签: css angular angular-material