次のコードがあります。私は彼らが属している要素から矢印でツールチップを取得しようとしています。コード内で私が要素上で、ツールチップのための十分な余地がイマイチならば、私はそれを下に表示するチェックしそうjQuery UIのツールチップの位置を動的に設定する
.ui-tooltip-content {
position: relative;
padding: 1em;
}
.ui-tooltip-content::after {
content: '';
position: absolute;
border-style: solid;
display: block;
width: 0;
}
.top .ui-tooltip-content::after {
bottom: -10px;
border-color: #666 transparent;
border-width: 10px 10px 0;
}
.bottom .ui-tooltip-content::after {
top: -10px;
border-color: #666 transparent;
border-width: 0 10px 10px;
}
:
var topPosition = { my: 'center bottom', at: 'center top-10' };
var bottomPosition = { my: 'center top', at: 'center bottom+10' };
$(document).tooltip
({
tooltipClass: 'top',
position: topPosition,
open: function(e,ui){
var topOfToolTip = ui.tooltip.offset().top;
var elem = $(e.originalEvent.target);
if (elem.offset().top < topOfToolTip) {
pos = {my: 'center top', at: 'center bottom+10'};
ui.tooltip.position(pos);
ui.tooltip.addClass("bottom");
}
}
});
は、それから私は、次のCSSを持っています。それはうまくいく。しかし、私の問題は、そのとき矢印が間違った方向を指していることです。私が手動で下位の値を使用するクラスと位置を変更する場合は、上記のツールヒントを取得しようとすると、以下のように動作します。
問題は、位置が設定されていないように見えることです。だから誰かが私にこのことを教えてもらえますか?
この作業。私はあなたが 'using'属性で' position'オプションを使う方が良いと思っています。私はこの例を取った:http://jqueryui.com/tooltip/#custom-styleそしてあなたのスタイリングを適用した。それはまだ後ろです...しかし、これは私が示唆しているものです:https://jsfiddle.net/Twisty/vmmsb9vx/ – Twisty