I want to center a tooltip which can have a varying width depending on content
property.
I see in this example that we can moddify pseudo class, But it seems a little bit complicated.
$(".tooltip").prop('id', function(i){
return "p_number_"+i;
}).hover( function() {
var width = window.getComputedStyle( this, ':after').getPropertyValue('width');
document.styleSheets[0].addRule('#'+this.id+':after','margin-left: -"'+width/2+'px";');
})
There not a simplest solution ?