更改Angular 2组件的CSS

时间:2017-06-30 10:13:54

标签: css angular ng2-tag-input

我是网络开发的新手,希望在我的Angular 2应用程序中使用ng2-tag-input和Clarity UI Framework。

由于Clarity UI中有效的CSS样式,标记输入组件无法正确呈现。例如,以下是两个屏幕截图:

Tag input component rendered outside of .form-group

Tag input component rendered inside of .form-group

<div class="form-group">内部,删除按钮(x)未对齐。在这两种情况下,添加标记输入字段都未对齐等。

我应该如何修复样式?我正在寻找一个解决这个问题的一般策略和特定修复程序。

1 个答案:

答案 0 :(得分:1)

如果要在ng2-tag-input中使用自定义主题样式 只需看到此链接ng2-tag-input theme

将这个foundation-theme.scss文件放在组件级别中......并在组件stylesUrls:['./foundation-theme.scss']中提供scss路径,并根据需要更改基础主题中的样式。

<强>基础-theme.scss

 @import "../../../../../node_modules/ng2-tag-input/dist/modules/core/styles/core/_core.scss";

$foundation-primary: #00a6e8;
$foundation-primary-dark: darken($foundation-primary, 10%);

// this is the container's theme
$foundation-theme: (
    container-border-bottom: 1px solid $foundation-primary
);

// this is the tag's theme
$foundation-tag-theme: (
    background: $foundation-primary,
    background-focused: $foundation-primary-dark,
    background-active: $foundation-primary-dark,
    background-hover: $foundation-primary-dark,
    color: #fff,
    color-hover: #fff,
    border-radius: 2px
);

// this is the delete icon's theme
$foundation-icon-theme: (
    fill: #fff,
    fill-focus: #eee,
    transition: all 0.35s
);

// apply theme to the container
/deep/ .ng2-tag-input.foundation-theme {
    @include tag-input-theme($foundation-theme);
}

// apply theme to the tags
/deep/ .ng2-tag-input.foundation-theme tag {
    @include tag-theme($foundation-tag-theme);
}

// apply theme to the delete icon
/deep/ .ng2-tag-input.foundation-theme tag delete-icon {
    @include icon-theme($foundation-icon-theme);
}