3

ツールチップのバブルを中央に配置しようとしていますが、成功しません:(解決策は非常に単純だと思いますが、それを実現できないと思います。誰かが私を助けてくれますか?THX!!ここでフィドル
私のコード:

$(document).ready(function(){
$(".menu .a").hover(function() {
var checkWidth = $(this).outerWidth() - $(this).outerWidth()/2;
    $(this).next("em").css({left:checkWidth}).animate({opacity: "show"}, "slow");
    }, function() {
    $(this).next("em").animate({opacity: "hide"}, "fast");
    });
});
4

2 に答える 2

3

このフィドルはあなたのために働くはずです。ツールチップ自体の幅を考慮する必要があります。

var checkWidth = $(this).outerWidth() - $(this).outerWidth()/2 - $(this).next("em").outerWidth()/2;
于 2012-07-20T13:53:14.257 に答える
0

これはどう:

.menu li em {
white-space:nowrap;
background-color:red;
position: absolute;
margin-top:-100px;
margin-left: -50px; /* I added just this line */
text-align: center;
padding: 20px;
font:12px helvetica, arial, sans-serif;
display:none;
}
于 2012-07-20T13:55:34.987 に答える