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

时间:2019-11-12 09:43:51

标签: 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">

6 个答案:

答案 0 :(得分:0)

您可以为此使用常规CSS。

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

答案 1 :(得分:0)

对于悬停,您需要使用:hover编写css 对您来说,代码应如下所示:

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

答案 2 :(得分:0)

您定位的课程错误。试试这个

.popover-title:hover{
   color: #000;
  background-color: #fff;
}

根据需要更改colorbackground-color

答案 3 :(得分:0)

这会有所帮助。

.popover-title:hover {
    max-width: 200px;
    padding: 0.25rem 0.5rem;
    color: green;
    text-align: center;
    background-color: green;
    border-radius: 0.25rem;
  }

答案 4 :(得分:0)

为“ popover-title”类应用background-color属性,如下所示。

.popover-title:hover{
  background-color: #fff;
}

如果以上属性被覆盖,请使用!important。

.popover-title:hover{
  background-color: #fff!important;
}

答案 5 :(得分:0)

工具提示依赖于第三方库Tether进行定位。您必须包含propper.min.js或任何其他库

//common service to be used for logging errors
public static class ErrorLogService
{
    public static void LogError(Exception ex)
    {
        //Do what you want here, save log in database, send email to police station
    }
}