A better Tooltip with jQuery
在国外的一个网站上看到了一份不错的jQuery 插件,主要是样式挺好的,于是转了过来方便以后需要是拿来用之....
预览一下:
文件主要文件及目录:
- Images folder contains the following images:
- – - tipTip.png – created in Step 2
- – - tipMid.png – created in Step 2
- – - tipBtm.png – created in Step 2
- style.css – created in Step 3
- jquery-1.3.1.min.js – download this here
- jquery.betterTooltip.js – – created in Step 5
三个图片切片位置为:
由于是PNG格式,IE支持不是很好,载入的时候边框会黑一下,然后才会用图片填充(我刚用IE8 也是这样)
看了别人的回复后说有个 ie_pngfix 的东东,以后再研究一下...
如果实在不行,我不用PNG还不行....O(∩_∩)O哈哈~
CSS 主要文件如下:
width: 212px;
padding-top: 37px;
display: none;
position: absolute;
background: transparent url(images/tipTop.png) no-repeat top;}
.tipMid {background: transparent url(images/tipMid.png) repeat-y; padding: 0 25px 20px 25px;}
.tipBtm {background: transparent url(images/tipBtm.png) no-repeat bottombottom; height: 32px;}
jQeury:
/* Setup the options for the tooltip that can be
accessed from outside the plugin */
var defaults = {
speed: 200,
delay: 300
};
var options = $.extend(defaults, options);
/* Create a function that builds the tooltip
markup. Then, prepend the tooltip to the body */
getTip = function() {
var tTip =
"<div class='tip'>" +
"<div class='tipMid'>" +
"</div>" +
"<div class='tipBtm'></div>" +
"</div>";
return tTip;
}
$("body").prepend(getTip());
/* Give each item with the class associated with
the plugin the ability to call the tooltip */
$(this).each(function(){
var $this = $(this);
var tip = $('.tip');
var tipInner = $('.tip .tipMid');
var tTitle = (this.title);
this.title = "";
var offset = $(this).offset();
var tLeft = offset.left;
var tTop = offset.top;
var tWidth = $this.width();
var tHeight = $this.height();
/* Mouse over and out functions*/
$this.hover(function() {
tipInner.html(tTitle);
setTip(tTop, tLeft);
setTimer();
},
function() {
stopTimer();
tip.hide();
}
);
/* Delay the fade-in animation of the tooltip */
setTimer = function() {
$this.showTipTimer = setInterval("showTip()", defaults.delay);
}
stopTimer = function() {
clearInterval($this.showTipTimer);
}
/* Position the tooltip relative to the class
associated with the tooltip */
setTip = function(top, left){
var topOffset = tip.height();
var xTip = (left-30)+"px";
var yTip = (top-topOffset-60)+"px";
tip.css({'top' : yTip, 'left' : xTip});
}
/* This function stops the timer and creates the
fade-in animation */
showTip = function(){
stopTimer();
tip.animate({"top": "+=20px", "opacity": "toggle"}, defaults.speed);
}
});
};
示例代码:
<html xmlns="http://www.w3.org/1999/xhtml">
<link href="theme/style.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="js/jquery.betterTooltip.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.tTip').betterTooltip({speed: 150, delay: 300});
});
</script>
</head>
<body>
<div class="tTip" title="The letter T. ">What's the difference between here and there?</div>
<a href="#" title="http://flynn.cnblogs.com">My Blog</a>
</body>
</html>
源文件下载:点击下载
Demo 地址: 浏览Demo
原文地址:点击浏览
转载于:https://www.cnblogs.com/Flynn/archive/2010/06/02/1749747.html
A better Tooltip with jQuery相关推荐
- 为开发者准备的15 款Tooltip工具提示jQuery插件
http://www.admin10000.com/document/2332.html tooltip或者infotip或者hint,是一种常见的图形用户界面元素.它用于连同一个光标,通常是一个鼠标 ...
- 流行的jQuery信息提示插件(jQuery Tooltip Plugin)
流行的jQuery信息提示插件(jQuery Tooltip Plugin) Learning, by 木公. 信息提示虽然是小东西,但是在网站设计中却起到了巨大的作用.如果你网站的信息提示做的好,会 ...
- 推荐 25 个优雅的 jQuery Tooltip 插件
jQuery 工具提示可以让网站上一些小的帮助信息显示更加直观,提升用户的体验.下面我们为你推荐 25 个最好的工具提示插件: 1. jqTooltip jqTooltip 2. Pop! Simpl ...
- 30个非常流行的提示信息插件(jQuery Tooltip Plugin)
在网站的设计中,提示信息是非常细微的功能,但是起着非常重要的作用.如果你的网站中提示信息做的比较好,会给浏览者留下非常深刻的印象,同时也会起到非常好的网站宣传效果,下面介绍了30个比较流行提示信息插件 ...
- 流行的jQuery信息提示插件(jQuery Tooltip Plugin)【转】
流行的jQuery信息提示插件(jQuery Tooltip Plugin) Learning , by 木公. 信息提示虽然是小东西,但是在网站设计中却起到了巨大的作用.如果你网站的信息提示做的好, ...
- 超强1000个jquery极品插件!(连载中。。。。最近更新20090710)
花N长时间积累的Jquery插件,希望大家喜欢.大家还有什么新的插件,请留言,我们一并收录. 感谢大家的支持. ++++++++++++++++++++++++++++++++++++++++++++ ...
- jQuery:收集一些基于jQuery框架开发的控件/jquery插件2
Horizontal accordion: jQuery 基于jQuery开发,非常简单的水平方向折叠控件. 主页:http://letmehaveblog.blogspot.com/2007/10/ ...
- JQuery插件开发学习
插件是JQuery强大之处的体现,把最聪明的功能封装到插件中,可以为你及你的团队节省大量开发时间. 编写一个JQuery插件,在于给JQuery.fn加入新的功能属性,此处添加的对象属性名称就是你插件 ...
- jquery 特效专辑
提示框弹窗类 Facebox Facebox 是一个基于jQuery,Facebook-style的lightbox.能够展示示images,divs或者整个远程页面 . Facebox Simple ...
- 20 个免费的 jQuery 的工具提示插件:
本文介绍 20 个免费的 jQuery 的工具提示插件: TipTip ( Demo | Download ) TipTip是一个非常轻量级的Tooltip jQuery插件.没有使用图片完全通过CS ...
最新文章
- 2 datax mysql 和 mysql之间相互导入
- 戴维南定律和诺顿定律
- python函数编程训练题_Python文件与函数练习题
- 2058. 找出临界点之间的最小和最大距离
- array js 二分法_JS常见的算法
- 基于JAVA+SpringMVC+Mybatis+MYSQL的学生请假管理系统
- Oracle中多表联合更新处理方法详解
- 数电渣渣的一点学习感想(更新中)
- 关于单利模式的几种实现方式
- 互联网基础运维分工、职责和技能要求
- 三菱plc可以用c语言编程吗,三菱PLC高手进-c语言编程题库
- android点击不同次切换不同图片,Android实现简单的上一张、下一张图片切换显示...
- hexo 炫酷主题配置
- 企业私有云搭建与作用
- 11月最新系统GHOST XP SP3 电脑城快速装机版 V2011.11
- ffmpeg合并多个MP4视频
- NEFU OJ 574 丑数
- 使用Jquery制作精美的图片展示效果
- 微信小程序上传图片(前端+PHP后端)
- Linux TCP在3.18内核引入的一个慢启动相关的问题或者说Bug
热门文章
- Google Authenticator(谷歌身份验证器)在苹果手机上IOS系统中 输入密钥时提示密钥无效的解决方案
- unite_Unite 2016主题总结:有关图形,平台,VR等的新闻
- 山东大学项目实训设计系统(四)管理员端
- 针对全局的接口出入参加解密-AES/ECB/PKCS5Padding
- TIFF图像文件格式详解(3)
- 浮山中学2021年高考成绩查询入口,浮山中学2019年高考成绩通报,第二波震撼来袭...
- 关于Socket的建立及连接
- 区块链技术如何让租房市场回归理性?
- VSCode 过滤.meta 文件
- 【PyG】文档总结以及项目经验(持续更新