gpt4 book ai didi

css - 更改默认扩展面板箭头的箭头样式

转载 作者:技术小花猫 更新时间:2023-10-29 11:15:09 24 4
gpt4 key购买 nike

我有一个 Angular 扩展面板,如下所示。

enter image description here

但是我想把箭头的设计改成这样:

未展开:

enter image description here

展开:

enter image description here

如何?或者我可以用 Angular Material 这样做吗?代码如下:

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>

TS:

import {Component} from '@angular/core';

/**
* @title Basic expansion panel
*/
@Component({
selector: 'expansion-overview-example',
templateUrl: 'expansion-overview-example.html',
})
export class ExpansionOverviewExample {}

最佳答案

是的,这是可能的。为您的扩展面板提供一个引用 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>

要在图标和面板描述之间留出空间,请在您的 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;
}

我使用了 Material 图标。如果需要,您可以放置​​自定义图标。这是一个链接 stackblitz demo .

关于css - 更改默认扩展面板箭头的箭头样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46556130/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com