css - 我想在工具提示悬停时更改标题背景颜色

标签 css angular twitter-bootstrap

我想在悬停时更改背景颜色标题,而不是在悬停时更改标题。 问题是当我悬停元素时,标题仍然是浅灰色(我认为是默认值颜色)。我想把背景改成黑色

<a class="popover-title" data-toggle="tooltip" data-trigger="hover"
                    title="test" 
             popover-append-to-body="true">

这种风格

 .myStyle{
    max-width: 200px;
    padding: 0.25rem 0.5rem;
    color: #fff;
    text-align: center;
    background-color: black;
    border-radius: 0.25rem;
  }

enter image description here enter image description here

已解决

我找到了解决方案

[data-title]:hover:after {
  opacity: 1;
  transition: all 0.1s ease 0.5s;
  visibility: visible;
}
[data-title]:after {
 content: attr(data-title);
 max-width: 200px;
 background-color: #000;
 color: #fff;
 position: absolute;
 text-align: center;
 padding:  0.25rem 0.5rem;
 border-radius: 0.25rem;
 font-style: normal;
 font-weight: 400;
 line-height: 1.5;
 z-index: 99999;
 visibility: hidden;
}
[data-title] {
  position: relative;
}

但问题是当我想翻译时它不起作用并且工具提示返回透明

<a class="font-weight-bold font-xs btn-block text-muted" data-toggle="tooltip" data-placement="bottom"
                [attr.data-title]="'test' | translate" 
          popover-append-to-body="true">

最佳答案

您可以为此使用传统的 CSS。

.popover-title:hover {
    background-color: black;
}

关于css - 我想在工具提示悬停时更改标题背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58815885/

相关文章:

javascript - 为什么这些元素不在它们的 DIV 容器中?

html - 禁用的按钮在 Angular 6 中不起作用

jquery - 如何在新的动态元素上应用 bootstrap css?

html - textarea bootstrap 3 中的值属性

html - 如何将整个图像放入 Bootstrap Carousel 中?

javascript - 页面在 IE 中完成加载时 MediaWiki 侧边栏回流

CSS:如何使背景图像 100% 高度,并保持纵横比

html - 简单的水平等分

c# - 带有 ASP-NET 和 Angular 的 Visual Studio 在浏览器中显示 TimeoutException

javascript - Typescript 严格的空检查和可观察过滤器