Centering tooltip?


Centering tooltip?



I'm trying to get my tooltip to be at the top & center of my page, regardless of window size and screensize. I have the following, but my tooltip appears on the top left corner:


<link rel="stylesheet" href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script>


<style>
area {
display: inline-block;
}



</style>

<script>
$(function() {
$( document ).tooltip({ position: {
my: "center bottom",
at: "center top",
}
});


});

</script>





Can you please post you HTML code or create a jsfiddle? Using your JS code I can't reproduce the issue.
– Steve Mulvihill
Jul 2 at 1:05





is this more helpful @SteveMulvihill
– rndm
Jul 2 at 1:14





Please provide a Minimal, Complete, and Verifiable example. Please look at guide how do I ask a good question?
– caiovisk
Jul 2 at 3:11





It's look like you are using Jquery UI so did you try the position option
– Core972
Jul 2 at 5:52




1 Answer
1



Try to center in this way:


$(".tip_holder").hover(function(){
var currentTipHolder = $(this);
var $tipTxt = $(this).text();
var $tipTitle = $(this).attr('title');

$('#icis_dashboard').prepend('<div id="tooltip">' + $tipTxt + '</div>');

// jQueryUI position
$('#tooltip').position({
of: currentTipHolder,
at: 'center top',
my: 'center bottom'
});
},function() {
$('#tooltip').remove();
});






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

How to make file upload 'Required' in Contact Form 7?

Rothschild family

amazon EC2 - How to make wp-config.php to writable?