无论窗口大小和屏幕大小如何,我都试图让我的工具提示位于页面的顶部和中心。我有以下内容,但我的工具提示出现在左上角:
<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>
最佳答案
- 请使用最新版本的 iQuery
尝试以这种方式居中:
$(".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(); });
关于html - 居中工具提示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51128058/