0

I try to apply a CSS to all the tooltip on my html page but can't find the way to do it.

I have done my research and found some results here, and there for instance, but can't make it work.

Here is part from my html page:

<div class="col-sm-3 text-center" title="Tooltip title"> </div>

And since I reference all the tooltips on this page:

(function (window, $) {   
    // Set the Tooltips
    $(document).ready(function(){
        $(document).tooltip({
            tooltipClass: "tooltip-styling"
        });
    });
})(window, $);

tooltip-styling is the following CSS class:

.tooltip-styling{
    background-color:red !important;
    color: red !important;
}

Nothing fancy, just wanted to check if the style is applied.

As you have guessed, it is not.

What should i do more?

Sanjeev Kumar
  • 3,113
  • 5
  • 36
  • 77
Mornor
  • 3,471
  • 8
  • 31
  • 69
  • `$('.selector').tooltip({ tooltipClass: "tooltip-styling", });` –  Jul 20 '16 at 09:13
  • Possible duplicate of [Overriding CSS styles of the jQuery UI Tooltip widget](http://stackoverflow.com/questions/4780759/overriding-css-styles-of-the-jquery-ui-tooltip-widget) –  Jul 20 '16 at 09:14

2 Answers2

2

Try this:

$( ".selector" ).tooltip( "option", "tooltipClass", "custom-tooltip-styling" );

As explained here: Here

Mayank Pandeyz
  • 25,704
  • 4
  • 40
  • 59
2

Fitting your case, the css declaration you have to overwrite is "background" and not "background-color".

https://jsfiddle.net/nrnLgc36/1/

html

<div class="col-sm-3 text-center" title="Tooltip title">TEST</div>

css

.tooltip-styling{
    background:green !important;
    color: black !important;
}

.col-sm-3 {
  display: block;
  background: #bacd63;
}

javascript

(function (window, $) {

    // Set the Tooltips
    $(document).ready(function(){
        $(document).tooltip({
            tooltipClass: "tooltip-styling"
        });
    });
})(window, $);
Nineoclick
  • 804
  • 9
  • 17