鼠标经过,显示层并跟随鼠标

效果图:

HTML:

<script src="../js/jquery-1.7.2.min.js" type="text/javascript"></script>
    <style type="text/css">
        .userInfo{ cursor:pointer; }
        .userInfoCont{ position:absolute; display:none; width:500px; background:#F2F2F2; border:5px solid #F2F2F2; z-index:99;}
    </style>
    <script type="text/javascript">
        $(function(){
            var xOffset = 10;
            var yOffset = 20;
            var w = $(window).width();
            var y = $(window).height();
            $(".userInfo").hover(function(e){
                    if(e.pageX < w/2){
                        $(this).find(".userInfoCont").show().css({
                            left: e.pageX + xOffset + "px",
                            right: "auto"
                        }).fadeIn("fast");
                    }else{
                        $(this).find(".userInfoCont").show().css("right",(w - e.pageX + yOffset) + "px").css("left", "auto").fadeIn("fast");    
                    }
                    if(e.pageY < y/2){
                        $(this).find(".userInfoCont").show().css({
                            top: e.pageY + xOffset + "px",
                            bottom: "auto"
                        }).fadeIn("fast");
                    }else{
                        $(this).find(".userInfoCont").show().css("bottom",(y - e.pageY + yOffset) + "px").css("top", "auto").fadeIn("fast");    
                    }
                },function(){
                    $(this).find(".userInfoCont").fadeOut("fast");
                    }).mousemove(function(e){
                            if(e.pageX < w/2){
                                $(this).find(".userInfoCont").show().css("left",(e.pageX + yOffset) + "px").css("right","auto");
                            }else{
                                $(this).find(".userInfoCont").show().css("right",(w - e.pageX + yOffset) + "px").css("left","auto");
                            }
                            if(e.pageY < y/2){
                                $(this).find(".userInfoCont").show().css({
                                    top: e.pageY + xOffset + "px",
                                    bottom: "auto"
                                }).fadeIn("fast");
                            }else{
                                $(this).find(".userInfoCont").show().css("bottom",(y - e.pageY + yOffset) + "px").css("top", "auto").fadeIn("fast");    
                            }
                        });    
        });
    </script>
<td class="userInfo">
   已用 
  <div style="display: none; left: 331px; right: auto; top: 234px; bottom: auto;" class="userInfoCont">
   <table border="1" width="100%" class="tbDefault">
    <tbody>
     <tr>
      <td colspan="4">课室使用信息</td>
     </tr>
     <tr>
      <td width="80" class="tdRight">周次:</td>
      <td width="170" class="tdLeft">1</td>
      <td width="80" class="tdRight">日期:</td>
      <td width="170" class="tdLeft">2014-09-08</td>
     </tr>
     <tr>
      <td width="80" class="tdRight">星期:</td>
      <td width="170" class="tdLeft"></td>
      <td width="80" class="tdRight">节次:</td>
      <td width="170" class="tdLeft">一二</td>
     </tr>
     <tr>
      <td width="80" class="tdRight">课程名称:</td>
      <td width="170" class="tdLeft">眼科学</td>
      <td width="80" class="tdRight">授课内容:</td>
      <td width="170" class="tdLeft">课程内容8</td>
     </tr>
     <tr>
      <td width="80" class="tdRight">节数:</td>
      <td width="170" class="tdLeft">2</td>
      <td width="80" class="tdRight">授课教师:</td>
      <td width="170" class="tdLeft">陈畅</td>
     </tr>
     <tr>
      <td width="80" class="tdRight">授课形式:</td>
      <td width="170" class="tdLeft">理论课</td>
      <td width="80" class="tdRight">授课地点:</td>
      <td width="170" class="tdLeft">本部教学楼201教室</td>
     </tr>
     <tr>
      <td width="80" class="tdRight">班级:</td>
      <td width="170" class="tdLeft">2014级七年制EIP3班</td>
      <td width="80" class="tdRight">学生数:</td>
      <td width="170" class="tdLeft">40</td>
     </tr>
    </tbody>
   </table>
  </div> 
</td>

 

参考:http://www.zhangxinxu.com/wordpress/2009/10/jquery-鼠标经过显示大图并跟随鼠标效果插件/

参考实例:http://www.zhangxinxu.com/study/200910/jQuery-plugin-image-big-show.html

 

转载于:https://www.cnblogs.com/linyongqin/articles/4239174.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值