我有一个tooltip
,就像facebook notification
一样,它的工作正常。实际上问题是我在页脚中插入toolip
的链接,当我点击工具提示正确打开的链接时,但当我想看到工具提示时,我手动将页面滚动条向下移动。我希望如果单击工具提示,页面会聚焦工具提示,我的意思是当工具提示打开时,滚动条会自动关闭。
HTML:
<div style="margin:0 auto;width:261px">
<ul id="nav">
<li id="notification_li"> <a href="#" id="notificationLink">
<h3>Title Awards</h3>
</a>
<div id="notificationContainer">
<!--<div id="notificationTitle">User Achieved Titles</div>-->
<div id="notificationsBody" class="notifications"> this is a content area in the div </div>
</li>
</ul>
</div>
CSS:
body {
font-family: arial
}
#nav {
list-style: none;
margin: 0px;
padding: 0px;
text-align: center;
background-color: #CCC;
}
#nav li {
float: left;
margin-right: 20px;
font-size: 10px;
font-weight: bold;
}
#nav li a {
color: Blue;
text-decoration: none;
}
#nav li a:hover {
color: #00FF00;
text-decoration: none
}
#notification_li {
position: relative;
}
#notificationContainer {
border-radius: 6px;
background-color: #FFF;
border: 1px solid rgba(100, 100, 100, .4);
-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);
overflow: visible;
position: absolute;
margin-left: -70px;
width: 261px;
z-index: 2;
display: none;
}
#notificationContainer:before {
content: '';
display: block;
position: absolute;
width: 0;
height: 0;
color: transparent;
border: 10px solid black;
border-color: transparent transparent #09F;
margin-top: -20px;
margin-left: 100px;
border-radius: 4px;
}
#notificationTitle {
z-index: 1000;
font-weight: bold;
padding: 8px;
font-size: 13px;
background-color: #09F;
width: 245px;
border-bottom: 1px solid #dddddd;
}
#notificationsBody {
/*padding: 33px 0px 0px 0px !important;*/
min-height: 100px;
}
#notificationFooter {
background-color: #e9eaed;
text-align: center;
font-weight: bold;
padding: 8px;
font-size: 12px;
}
jQuery的:
$(document).ready(function()
{
$("#notificationLink").click(function()
{
$("#notificationContainer").fadeToggle(500);
$("#notification_count").fadeOut("slow");
return false;
});
//Document Click
$(document).click(function()
{
$("#notificationContainer").hide();
});
//Popup Click
$("#notificationContainer").click(function()
{
return false
});
});
答案 0 :(得分:0)
在onclick处理程序中添加:
$("body").scrollTop($("#[tooltip selector]").offset().top);
修改:scrollTo无效,因此将其更改为scrollTop