css - 为什么我无法更改工具提示背景颜色?

标签 css angular5

我正在尝试更改工具提示背景颜色。我已经尝试遵循 CSS。

<i *ngIf="col.field != 'isActive' && col.field != 'action'" class="fa fa-info-circle" aria-hidden="true" pTooltip="{{col.title}}" tooltipPosition="top" style="font-size:12px;">
</i>

CSS:

.ui-tooltip-text.ui-shadow.ui-corner-all {
    background-color: red;
}

但是背景颜色没有改变。 有没有人有这方面的经验?

最佳答案

Option 1

如果你在组件 CSS 文件中编写你的 CSS 它不会应用到你的工具提示上。因为 tooltip 添加在主体根路径中,所以您必须在组件中添加 ViewEncapsulation。请查看以下代码段。

Working Example

import { Component, ViewEncapsulation } from '@angular/core';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ],
  encapsulation: ViewEncapsulation.None,
})
export class AppComponent  {
}

Option 2

Global css 文件中写入您的 css,该文件位于您的元素 src > assets > css 中。

关于css - 为什么我无法更改工具提示背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56286209/

相关文章:

javascript - jScrollPane 和相对宽度?

kendo-grid - 带有工具提示的 Angular Grid 剑道

angular - Angular 5 中日期时间选择器中的回调方法

html - 错误错误 : ExpressionChangedAfterItHasBeenCheckedError in Angular 5

angular - 使用angular将隐藏参数传递给外部链接

html - 选择框文本卡在 FF 中的框顶部

css - 在 Chrome 中应用 CSS 转换后,SVG 上的 CSS 阴影失真

android - 限制移动设备的悬停功能

php - 为嵌套类(社交链接)指定 URL 属性,但它仍然作为父类(标题)的属性工作,我该如何解决?

asp.net-core - 带有 Angular 5 的 ASP.NET Core -- 何时使用 Assets 文件夹与 wwwroot 文件夹?