gpt4 book ai didi

css - 更改 Angular 2 组件的 CSS

转载 作者:太空宇宙 更新时间:2023-11-04 08:30:17 25 4
gpt4 key购买 nike

我是网络开发的新手,想在我的 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) 未对齐。在这两种情况下,添加标签输入字段都未对齐等。

我应该如何修复样式?我正在寻找解决此问题的一般策略和特定修复方法。

最佳答案

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

将这个 foundation-theme.scss 文件放在你的组件级别..并在你的组件 stylesUrls:['./foundation-theme.scss'] 中提供 scss 路径并更改 foundation 中的样式主题随心所欲。

foundation-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);
}

关于css - 更改 Angular 2 组件的 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44844033/

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