jquery实现的获取鼠标位置并弹出提示框
2012-11-19 15:54
639 查看
在做Web应用的时候,有时候为了增强用户体验,当用户鼠标放在某个图片或者按钮上时,需要给一些互动性的提示。当然,HTML中已经自带了这项功能,就是alt=“”,但有时觉得这个看起来不够美观,所以就自己用css写了个弹出框,并用jquery实现了效果,代码如下:
效果图片如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gbk" /> <script type="text/javascript" src="jquery.js"></script> <title>HTML+CSS圆角提示框</title> <style type="text/css"> /*提示圆角框*/ .circle_bot { width:80px; clear:both; font: 15px/1.125 Arial; display:none;z-index: 9999;position: absolute;} .circle_bot .s_b b, .circle_bot span.s_i i { font-size:1px; line-height:1px; overflow:hidden; display:block; clear:both;z-index: 9999;} .circle_bot .s_b b, .circle_bot span.s_i i, .circle_bot .info { background:#FAFFF0; border:#000 solid; z-index: 9999;} .circle_bot b.b1 { border-width:1px 0 0 0; margin:0 2px; height:0px; z-index: 9999;} .circle_bot b.b2 { border-width:0 1px; margin:0 1px; height:1px; z-index: 9999;} .circle_bot span.s_i i { height:1px; border-width:0 1px; z-index: 9999;} .circle_bot .i1 { width:0px; margin-left:36px; z-index: 9999;} .circle_bot .i2 { width:2px; margin-left:35px; z-index: 9999;} .circle_bot .i3 { width:4px; margin-left:34px; z-index: 9999;} .circle_bot .i4 { width:6px; margin-left:33px; z-index: 9999;} .circle_bot .i5 { width:8px; margin-left:32px; z-index: 9999;} .circle_bot .i6 { width:10px; margin-left:31px; margin-top:-1px;z-index: 9999;} .circle_bot .info { border-width:0 1px; color:#333; padding:5px;z-index: 9999;} </style> <script text="text/javascript"> $(function(){ var tip = $(".circle_bot"); $("#button").mouseover(function(e){ tip.css("margin-left",e.pageX-50+"px").css("margin-top",e.pageY-50+"px"); tip.css("display","block"); }) $("#button").mouseout(function(){ tip.css("display","none"); }) }) </script> </head> <body> <div class="circle_bot"> <span class="s_b"> <b class="b1"></b> <b class="b2"></b></span> <div class="info">提示提示</div> <span class="s_b"><b class="b2"></b> <b class="b1"></b></span> <span class="s_i"> <i class="i6"></i> <i class="i5"></i> <i class="i4"></i> <i class="i3"></i> <i class="i2"></i> <i class="i1"></i></span> </div> <div><img style="margin-left:100px; margin-top:100px;" src="logo.png" id="button"></div> </body> </html>
效果图片如下:
相关文章推荐
- jquery实现div遮罩效果,并获取鼠标位置。
- jQuery实现获取table中鼠标click点击位置行号与列号的方法
- jQuery实现鼠标选中文字后弹出提示窗口效果【附demo源码】
- jQuery实现鼠标经过弹出提示信息的地图热点效果
- jQuery实现鼠标经过弹出提示信息的地图热点效果
- Jquery实现鼠标hover图片遮罩弹出提示层特效
- JQuery实现感应鼠标弹出气泡框悬停提示的js特效
- js与jquery中获取当前鼠标的x、y坐标位置的代码
- JQuery实现一个简单的鼠标跟随提示效果
- 基于 jQuery & CSS3 实现智能提示输入框光标位置
- Js和JQuery获取鼠标指针坐标的实现代码分享
- jQuery实现点击文本框弹出热门标签的提示效果
- jQuery实现的鼠标滑过弹出放大图片特效
- Jquery实现鼠标移上弹出提示框、移出消失思路及代码
- Jquery实现鼠标移到某个对象,弹出显示层。
- jQuery实现表单input中提示文字value随鼠标焦点移进移出而显示或隐藏的代码
- jQuery实现鼠标移上弹出提示框,移出消失
- 鼠标设置Jquery实现鼠标移上弹出提示框,移出消失
- 实现在Picture控件中获取鼠标位置(OnMouseMove)