html - 禁用样式(垫扩展面板)

标签 html css angular-material

如何在禁用时隐藏此 mat-expansion-panel 背景?

我已经添加了这个css

::ng-deep .mat-expansion-panel-header[aria-disabled=true] {
border-radius: 10px;
background-color: rgba(0,0,0,.26) !important;
color: rgb(107, 190, 198) !important;}

但轮到它像this

我也尝试从浏览器检查元素并找到一个类

.mat-expansion-panel {
background: #fff;
color: rgba(0,0,0,.87);}

当我尝试取消选中“背景”时,白色背景消失了,但我不知道我必须在 css 中做什么

最佳答案

背景由 mat-expansion-panel 添加,它是 .mat-expansion-panel-header 的父级。因此,您想根据子项的属性 (aria-disabled) 更改父项样式。

这是 css 做不到的。

您可能要做的是将 .mat-expansion-panel(parent)背景颜色设置为默认透明。所以覆盖初始值。并将 background-color:#fff 添加到 panel-header 中。然后在它被禁用时覆盖它。

::ng-deep .mat-expansion-panel{
    background: transparent;
    color: rgba(0,0,0,0); /* transparent */
}
::ng-deep .mat-expansion-panel-header{
    /* styles that were added to panel before */
    background: #fff;
    color: rgba(0,0,0,.87); 
}


::ng-deep .mat-expansion-panel-header[aria-disabled=true] {
    /* change what you want */
    border-radius: 10px;
    background: rgba(0,0,0,.26);
    color: rgb(107, 190, 198);
}

关于html - 禁用样式(垫扩展面板),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55453232/

相关文章:

javascript - 在html中 float 多个元素

javascript - 给定超时后关闭 md-tooltip

angular - 如何同步两个 Angular Material 分页器?

angularjs - 使用 md-button 时出现 ng-transclude 错误

html - 如何使 bootstrap css 输入附加按钮和错误范围看起来不错

html - Google Captcha 的定位在台式机/平板电脑上运行良好,但在移动设备上运行不佳

javascript - MutationObserver 观察样式变化仅触发一次

javascript - 从 ajax 调用获取 HTML 或 JSON 响应,哪个好?

html - 将图标垂直对齐到第一行文本的中心

html - CSS FlexBox 和图像调整大小