【问题标题】:Change color of contents in Mat Expansion on hover and focus在悬停和聚焦时更改 Mat Expansion 中内容的颜色
【发布时间】:2019-06-24 19:08:38
【问题描述】:

我正在编写 css 来更改焦点和悬停时文本和箭头指示器的颜色。然而,指示箭头单独作用。当您将鼠标悬停在整个面板上时,我希望它发生变化。目前箭头指示器仅在您直接悬停在它上面时才会发生变化基本上当整个面板具有焦点或悬停时将标题和指示器更改为我的 css:https://stackblitz.com/edit/angular-imycgv?file=styles.css

.mat-expansion-indicator:hover::after,
.mat-expansion-indicator:focus::after{
  color: yellow;
}

.mat-expansion-panel:hover,
.mat-expansion-panel:focus{
  background-color: red;
}
.mat-expansion-panel-header-description:hover, .mat-expansion-panel-header-title:hover,
.mat-expansion-panel-header-description:focus, .mat-expansion-panel-header-title:focus{
  color: orange;
}
    }

【问题讨论】:

    标签: css angular material-design


    【解决方案1】:

    要达到预期的效果,请使用以下选项 mat-expansion-indicator 不是面板的直接子级,所以面板的悬停,改变指示器的颜色

    .mat-expansion-panel:hover  .mat-expansion-indicator::after,
    .mat-expansion-panel:focus  .mat-expansion-indicator::after{
      color: yellow;
    }
    

    codesandbox 供参考 - https://codesandbox.io/s/angular-hh3oz

    【讨论】:

    • 我试图将它保存在 stackblitz 中,由于某种原因它不允许我保存,将所有内容复制到代码和框,希望它可以工作:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-02
    • 1970-01-01
    • 2021-11-23
    • 2013-10-12
    • 2023-04-01
    • 2020-10-12
    • 2018-02-27
    相关资源
    最近更新 更多