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?

2
  • $('.selector').tooltip({ tooltipClass: "tooltip-styling", }); Commented Jul 20, 2016 at 9:13
  • Possible duplicate of Overriding CSS styles of the jQuery UI Tooltip widget Commented Jul 20, 2016 at 9:14

2 Answers 2

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, $);
Sign up to request clarification or add additional context in comments.

1 Comment

That was it ... Thanks!
2

Try this:

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

As explained here: Here

1 Comment

I think it is exactly the same as my code, isn't it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.