Jquery11_仿QQ右下方提示

来源:互联网 发布:淘宝隐藏优惠券领取 编辑:程序博客网 时间:2024/05/16 05:21

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style type="text/css">
       
       #tip{ position:fixed;right:0px; bottom:-180px;}  <!--定位一定要设置成fixed 不然会随着滚动条改变位置-->
    </style>

    <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            // 默认从浏览器右下角出来
            $("#tip").animate({ "bottom": "0px" }, 600);

            // 默认4秒后抖动一下
            setTimeout(
               function () {

                   for (var i = 0; i < 30; i++) {
                       var ranNum = parseInt(Math.random() * 8 + 1);
                       $("#tip").animate({ "bottom": ranNum, "right": ranNum }, 15);

                   };
                   // 矫正
                   $("#tip").animate({ "bottom": "0px", "right": "0px" }, 10);

               }, 4000);

            // 默认9秒后自动消失
            setTimeout(function () {
                $("#tip").animate({ "bottom": "-180px" }, 1000)
            }, 9000);


            // 点击关闭时
            $("#close").click(function () {
                $("#tip").animate({ "bottom": "-180px" }, 300, function () {
                    $(this).remove();
                });
            });
        });


    </script>
</head>
<body>
    <div id="tip">
       <table style="width:200px;height:150px;">
          <tr style="width:200px;height:25px;background:#CC6633;">
              <td>
                新的留言板回复   <a id="close" href="#">关闭 X</a>
              </td>
          </tr>
           <tr style="width:200px;height:100px;background:#CCCC99;">
              <td>
                  你的好友(xxx)发表盘了留言赶快去回复吧!点此直接转到留言板http://www.QQZoom.com
              </td>
          </tr>
           <tr style="width:200px;height:25px;background:#CC6633;">
              <td style="text-align:right;">
                 <a href="#">查看</a>
              </td>
          </tr>
       </table>
    </div>
   
</body>
</html>

原创粉丝点击