請檢出這個jsfiddle,當我點擊一個標籤定位點時我希望標籤菜單(div)出現在定位元素旁邊,但是從TOP RIGHT而不是TOP左邊,我嘗試過使用膠印,但到目前爲止我還沒有取得成功。jQuery:如何讓隱藏的div從右上角出現
下面的代碼:
HTML:
<div id="tag-menu"></div>
<span class="edit-tags-wrapper" style="float:right;">
<a rel="tag" title="show questions tagged 'jquery'" class="post-tag" href="#">jquery</a>
<a rel="tag" title="show questions tagged 'animation'" class="post-tag" href="#">animation</a>
<a rel="tag" title="show questions tagged 'tags'" class="post-tag" href="#">tags</a>
<a rel="tag" title="" class="post-tag" href="#">stackoverflow</a>
JS:
$('a.post-tag').click(function(){
var $this = $(this);
var offset = $this.offset();
var myPos = {X:offset.left, Y:offset.top+26};
$('#tag-menu').css({left:myPos.X, top:myPos.Y, width:300, height:200}).toggle();
});
CSS:
.post-tag{
background:#e0eaf1;
border-right:1px solid #3E6D8E;
border-bottom:1px solid #3E6D8E;
padding:2px 5px;
color:#4a6b82;
}
.post-tag{
text-decoration:none;
}
.post-tag:hover{
background:#3E6D8E;
color:#fff;
}
#tag-menu{
background:#666;
position:absolute;
display:none;
box-shadow:0 2px 3px #000;
border-radius:5px;
}
,或者您可以簽出的jsfiddle運行它
http://jsfiddle.net/EBergman/xfVaT/
非常感謝羅克森,這正是我想要的,你是一個天才!我不知道你是否記得,但是這是你創建的演示,回到我在這裏問的另一個問題。 –
@EricBergman哦!謝謝!真!哇!這就是爲什麼你的名字很熟悉!別客氣! (是的!演示也有點熟悉:)) –
@EricBergman http://stackoverflow.com/questions/14200320/what-type-of-animation-does-stackoverflow-use-for-tag-popup :) –