【问题标题】:Akveo Nebular Angular ThemeAkveo 星云角主题
【发布时间】:2020-03-27 04:23:17
【问题描述】:

我正在尝试从 Nebular 重写一些 Accordion 组件的样式,但如果我启用多个主题模式,它就不起作用。

如果我在不支持多个主题的情况下设置组件样式,它确实有效:

@import "../../@theme/styles/themes.scss";
$border: red;

.contato {
  margin-bottom: 5px !important;
}

nb-accordion nb-accordion-item:last-child.collapsed nb-accordion-item-header {
  border-radius: 5px;
  background-color: $border !important;
}

但如果我按照https://akveo.github.io/nebular/docs/design-system/use-theme-variables#access-with-multiples-theme-mode 中的说明启用多个主题,它就不起作用了:

@import "../../@theme/styles/themes.scss";
@include nb-install-component {
  $border: nb-theme(background-alternative-color-4);

  .contato {
    margin-bottom: 5px !important;
  }

  nb-accordion nb-accordion-item:last-child.collapsed nb-accordion-item-header {
    border-radius: 5px;
    background-color: $border !important;
  }
}

组件的背景颜色保持不变。

怎么了?我需要启用其他功能吗?

  • 星云 5。

谢谢,

【问题讨论】:

    标签: angular nebular


    【解决方案1】:

    将 ::ng-deep 添加到 css 类对我有用:

    @import "../../@theme/styles/themes.scss";
    @include nb-install-component {
      $border: nb-theme(background-alternative-color-4);
    
      ::ng-deep .contato {
        margin-bottom: 5px !important;
      }
    
      ::ng-deep nb-accordion nb-accordion-item:last-child.collapsed nb-accordion-item-header {
        border-radius: 5px;
        background-color: $border !important;
      }
    }
    

    参见 ng-deep 文档here

    【讨论】:

    • 是的,克里斯蒂安,::ng-deep 使我免于许多麻烦,但在这种情况下,我认为我的自定义主题本身有问题,因为不起作用的是 SASS 变量替换。最后,我只是更改了默认主题,稍后我将了解如何从头开始创建全新的主题。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多