Clo*_*eph 7 css angular-material angular-material2 angular
我有一个角度扩展面板,如下所示.
但我想将箭头的设计改为这样的:
没有扩大:
扩展:
怎么样?或者我可以用棱角分明的材料吗?代码如下:
HTML:
<md-expansion-panel>
<md-expansion-panel-header>
<md-panel-title>
Personal data
</md-panel-title>
<md-panel-description>
Type your name and age
</md-panel-description>
</md-expansion-panel-header>
<md-form-field>
<input mdInput placeholder="First name">
</md-form-field>
<md-form-field>
<input mdInput placeholder="Age">
</md-form-field>
</md-expansion-panel>
Run Code Online (Sandbox Code Playgroud)
TS:
import {Component} from '@angular/core';
/**
* @title Basic expansion panel
*/
@Component({
selector: 'expansion-overview-example',
templateUrl: 'expansion-overview-example.html',
})
export class ExpansionOverviewExample {}
Run Code Online (Sandbox Code Playgroud)
Fai*_*sal 17
对的,这是可能的.为您的扩展面板提供参考ID,例如example将hideToggle属性设置为true.
在中<md-panel-description>,您可以放置图标并使用expanded面板的属性来显示或隐藏相关图标.
<md-expansion-panel class="custom-header" hideToggle="true" #example>
<md-expansion-panel-header>
<md-panel-title>
Personal data
</md-panel-title>
<md-panel-description>
Type your name and age
<md-icon *ngIf="!example.expanded">play_arrow</md-icon>
<md-icon *ngIf="example.expanded">arrow_drop_down</md-icon>
</md-panel-description>
</md-expansion-panel-header>
<md-form-field>
<input mdInput placeholder="First name">
</md-form-field>
<md-form-field>
<input mdInput placeholder="Age">
</md-form-field>
</md-expansion-panel>
Run Code Online (Sandbox Code Playgroud)
要在图标和面板描述之间提供空间,请在component.css中添加以下类:
.custom-header .mat-expansion-panel-header-title,
.custom-header .mat-expansion-panel-header-description {
flex-basis: 0;
}
.custom-header .mat-expansion-panel-header-description {
justify-content: space-between;
align-items: center;
}
Run Code Online (Sandbox Code Playgroud)
我用过材料图标.您可以根据需要放置自定义图标.这是stackblitz演示的链接.
扩展了@Faisal 的答案,根据最新版本的角度材料,我们将使用mat前缀而不是md材料组件。
角材料 8.1.4
<mat-expansion-panel class="mb-15px" hideToggle="true" #xyz>
<mat-expansion-panel-header>
<mat-panel-title class="font-weight-bold font-small">
Info
</mat-panel-title>
<mat-panel-description>
<mat-icon *ngIf="!xyz.expanded">play_arrow</mat-icon>
<mat-icon *ngIf="xyz.expanded">arrow_drop_down</mat-icon>
</mat-panel-description>
</mat-expansion-panel-header>
<mat-expansion-panel class="mb-15px" hideToggle="true" #xyz>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9515 次 |
| 最近记录: |