jQuery UI 工具提示位置的奇怪行为
jQuery UI ToolTip strange behavior of position
jsfiddle https://jsfiddle.net/qg43v53k/24/
我尝试将工具提示连接到表格单元格,表格的宽度大于窗口宽度。屏幕外单元格的工具提示宽度太小。我该如何解决这个问题。
网页代码
<table>
<tr>
<td class="tooltip" title="In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips." style="width:200px;">Some text</td>
<td class="tooltip" title="In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips." style="width:200px;">Some text</td>
<td class="tooltip" title="In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips." style="width:200px;">Some text</td>
<td class="tooltip" title="In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips." style="width:200px;">Some text</td>
<td class="tooltip" title="In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips." style="width:200px;">Some text</td>
<td class="tooltip" title="In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips." style="width:200px;">Some text</td>
<td class="tooltip" title="In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips." style="width:200px;">Some text</td>
</tr>
<tr>
<td class="tooltip" title="In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips." style="width:200px;">Some text</td>
<td class="tooltip" title="In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips." style="width:200px;">Some text</td>
<td class="tooltip" title="In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips." style="width:200px;">Some text</td>
<td class="tooltip" title="In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips." style="width:200px;">Some text</td>
<td class="tooltip" title="In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips." style="width:200px;">Some text</td>
<td class="tooltip" title="In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips." style="width:200px;">Some text</td>
<td class="tooltip" title="In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips." style="width:200px;">Some text</td>
</tr>
<tr>
<td class="tooltip" title="In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips." style="width:200px;">Some text</td>
<td class="tooltip" title="In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips." style="width:200px;">Some text</td>
<td class="tooltip" title="In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips." style="width:200px;">Some text</td>
<td class="tooltip" title="In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips." style="width:200px;">Some text</td>
<td class="tooltip" title="In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips." style="width:200px;">Some text</td>
<td class="tooltip" title="In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips." style="width:200px;">Some text</td>
<td class="tooltip" title="In general, disabled elements do not trigger any DOM events. Therefore, it is not possible to properly control tooltips for disabled elements, since we need to listen to events to determine when to show and hide the tooltip. As a result, jQuery UI does not guarantee any level of support for tooltips attached to disabled elements. Unfortunately, this means that if you require tooltips on disabled elements, you may end up with a mixture of native tooltips and jQuery UI tooltips." style="width:200px;">Some text</td>
</tr>
</table>
JavaScript
$('.tooltip').tooltip({
position: {
my: "center top",
at: "center bottom",
},
content: function() {
var element = $( this );
if ( element.is( "[title]" ) ) {
return element.attr( "title" );
}
if ( element.is( "img" ) ) {
return element.attr( "alt" );
}
},
});
.css
table{
margin-top:50px;
table-layout:fixed;
width:1400px;
}
table td{
border:1px solid;
padding:5px 10px;
}
一种可能实现您想要执行的操作的方法是在打开工具提示时显式设置工具提示的width
。
为此,可以将另一个事件的代码open
添加到现有.tooltip()
调用中,如下所示:
$('.tooltip').tooltip({
position: {
my: "center top",
at: "center bottom",
},
content: function() {
var element = $( this );
if ( element.is( "[title]" ) ) {
return element.attr( "title" );
}
if ( element.is( "img" ) ) {
return element.attr( "alt" );
}
},
open: function (event, ui) {
ui.tooltip.css("width", "400px");
}
});
您可以将此设置调整为适合您需求的任何width
。
这是一个更新的jsFiddle以查看结果:js小提琴
相关文章:
- jQuery UI工具提示:单击工具提示本身即可关闭
- jQuery UI 工具提示位置的奇怪行为
- d3.js svg元素上的角度UI工具提示
- jquery UI工具提示的自定义背景图像
- 剑道ui工具提示在网格中的定位问题
- jQuery UI 工具提示在源 DOM 元素移动时卡住打开
- IE8,jQuery UI 工具提示在 Internet Explorer 8 中立即关闭
- 无法将表单输入字段上的 JQuery UI 工具提示限制为仅在单击/焦点事件上显示
- 更新 jQuery UI 工具提示上的数字
- 如何使用 i18next 本地化属性(对于 jQuery UI 工具提示,在我的情况下使用标题)
- 在我的自定义指令中动态添加 bootstrap.ui 工具提示
- 在 jquery UI 工具提示中显示加载效果
- 如何为新加载的元素提供JQuery UI工具提示
- JQuery UI工具提示:每个工具提示有不同的图像
- JQuery UI工具提示-工具提示的位置错误(在页面左侧,而不是按钮周围)
- 如何使用jQuery UI工具提示在打开时更改工具提示颜色
- 同时显示两个jQuery UI工具提示
- 在动态元素上使用多个JQuery UI工具提示
- 剑道UI工具提示有时会在应该消失的时候仍然可见
- 获取对jQuery UI工具提示中悬停元素的引用