jQuery提示框插件tinyTips js代码

版权:原创 更新时间:1年以上
[该文章底部包含文件资源,可根据自己情况,决定是否下载资源使用,时间>金钱,如有需要,立即查看资源]

以下是 jQuery提示框插件tinyTips js代码 的示例演示效果:

当前平台(PC电脑)
  • 平台:

部分效果截图:

jQuery提示框插件tinyTips js代码

HTML代码(index.html):

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery提示框插件tinyTips</title>
<link rel="stylesheet" type="text/css" media="screen" href="styles/tinyTips.css" />
		<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
		<script type="text/javascript" src="js/jquery.tinyTips.js"></script>
		<script type="text/javascript">
		$(document).ready(function() {
			$('a.tTip').tinyTips('light', 'title');
			$('a.imgTip').tinyTips('yellow', '<img src="images/demo-image.jpg" /><br />You can even put images or any other markup in the tooltips.');
			$('img.tTip').tinyTips('green', 'title');
			$('h1.tagline').tinyTips('blue', 'tinyTips are totally awesome!');
		});
		</script>
	</head>
<body>
	<div id="demo_wrapper">
		<h1 class="massive">tinyTips</h1>
		<h1 class="tagline">Super-lightweight jQuery Tooltips.</h1>
		<p><img class="tTip" src="images/demo-image.jpg" title="Look at me, I'm a frog!" />Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
		<a class="tTip" href="#" title="This tooltip is using the title of this anchor tag.">Aenean ut nunc metus</a>, gravida tincidunt libero. 
		Proin molestie risus at odio luctus condimentum. Sed molestie bibendum orci a faucibus. Vivamus vel lorem ut augue laoreet cursus. 
		Maecenas vestibulum nibh non nibh viverra posuere. Sed <a class="tTip" href="#" title="This one is also using the title.">tristique eleifend</a> elit sit amet varius. 
		Curabitur augue purus, molestie eu hendrerit a, sollicitudin nec eros. Aliquam vitae pellentesque lorem. Vestibulum leo <a class="imgTip" href="#">tortor</a>, 
		luctus sed varius eu, ultrices ac sapien. Nulla pretium est eget mi 
		<a class="tTip" href="#" title="How about a really long one so we can test out positioning so it doesn't overlap the element the tooltip is for. 
		Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum eget purus a orci consequat congue. Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
		Suspendisse porttitor scelerisque leo, ut elementum nisi fermentum ac. Etiam mauris tellus, ornare sit amet venenatis at, vehicula vitae purus. 
		Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.">dignissim</a> sed 
		tincidunt eros porta. In ligula mauris, aliquam quis tempor quis, consectetur a erat. Nulla non justo 
		pellentesque dui elementum pharetra nec eu magna. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
	</div>
</body>
</html>









JS代码(jquery.tinyTips.js):

/***********************************************************/
/* tinyTips Plugin */
/* Version:1.1 */
/* Mike Merritt */
/* Updated:Mar 2nd,2010 */
/***********************************************************/
(function($){
	$.fn.tinyTips = function (tipColor,supCont){
	if (tipColor === 'null'){
	tipColor = 'light';
}
var tipName = tipColor + 'Tip';
	/* User settings**********************************/
// Enter the markup for your tooltips here. The wrapping div must have a class of tinyTip and// it must have a div with the class "content" somewhere inside of it.var tipFrame = '<div class="' + tipName + '"><div class="content"></div><div class="bottom">&nbsp;
	</div></div>';
	// Speed of the animations in milliseconds - 1000 = 1 second.var animSpeed = 300;
	/***************************************************************************************************/
/* End of user settings - Do not edit below this line unless you are trying to edit functionality. */
/***************************************************************************************************/
// Global tinyTip variables;
	var tinyTip;
	var tText;
	// When we hover over the element that we want the tooltip applied to$(this).hover(function(){
	// Inject the markup for the tooltip into the page and// set the tooltip global to the current markup and then hide it.$('body').append(tipFrame);
	var divTip = 'div.'+tipName;
	tinyTip = $(divTip);
	tinyTip.hide();
	// Grab the content for the tooltip from the title attribute (or the supplied content) and// inject it into the markup for the current tooltip. NOTE:title attribute is used unless// other content is supplied instead.if (supCont === 'title'){
	var tipCont = $(this).attr('title');
}
else if (supCont !== 'title'){
	var tipCont = supCont;
}
$(divTip + ' .content').html(tipCont);
	tText = $(this).attr('title');
	$(this).attr('title','');
	// Offsets so that the tooltip is centered over the element it is being applied to but// raise it up above the element so it isn't covering it.var yOffset = tinyTip.height() + 2;
	var xOffset = (tinyTip.width() / 2) - ($(this).width() / 2);
	// Grab the coordinates for the element with the tooltip and make a new copy// so that we can keep the original un-touched.var pos = $(this).offset();
	var nPos = pos;
	// Add the offsets to the tooltip positionnPos.top = pos.top - yOffset;
	nPos.left = pos.left - xOffset;
	// Make sure that the tooltip has absolute positioning and a high z-index,// then place it at the correct spot and fade it in.tinyTip.css('position','absolute').css('z-index','1000');
	tinyTip.css(nPos).fadeIn(animSpeed);
}
,function(){
	$(this).attr('title',tText);
	// Fade the tooltip out once the mouse moves away and then remove it from the DOM.tinyTip.fadeOut(animSpeed,function(){
	$(this).remove();
}
);
}
);
}
}
)(jQuery);
	

CSS代码(tinyTips.css):

@charset "utf-8";html{font-family:"Lucida Sans Unicode";font-size:14px;line-height:21px;color:#f1f1f1;background:#0b0b0b;}
body{}
p{color:#616161;}
a{color:#f1f1f1;}
img.tTip{margin:8px 15px 8px 0px;float:left;}
h1{text-align:center;line-height:15px;padding:0px 0px 20px 0px;letter-spacing:-2px;}
h1.massive{font-size:72px;line-height:10px;padding:0px;letter-spacing:-6px;color:#f4c20a;}
#demo_wrapper{width:600px;margin:30px auto 0px auto;}
.lightTip{}
.lightTip .content{width:310px;padding:10px;border:6px solid #e2e2e2;-moz-border-radius:5px;-webkit-border-radius:5px;background:#ffffff;color:#020202;}
.lightTip .bottom{height:14px;background:url(../images/notch-white.png) top center no-repeat;}
.yellowTip{}
.yellowTip .content{width:310px;padding:10px;border:6px solid #f9e98e;-moz-border-radius:5px;-webkit-border-radius:5px;background:#fbf7aa;color:#020202;}
.yellowTip .bottom{height:14px;background:url(../images/notch-yellow.png) top center no-repeat;}
.orangeTip{}
.orangeTip .content{width:310px;padding:10px;border:6px solid #f9cd8e;-moz-border-radius:5px;-webkit-border-radius:5px;background:#fbe3aa;color:#020202;}
.orangeTip .bottom{height:14px;background:url(../images/notch-orange.png) top center no-repeat;}
.redTip{}
.redTip .content{width:310px;padding:10px;border:6px solid #ce6f6f;-moz-border-radius:5px;-webkit-border-radius:5px;background:#f79992;color:#020202;}
.redTip .bottom{height:14px;background:url(../images/notch-red.png) top center no-repeat;}
.greenTip{}
.greenTip .content{width:310px;padding:10px;border:6px solid #a9db66;-moz-border-radius:5px;-webkit-border-radius:5px;background:#cae8a2;color:#020202;}
.greenTip .bottom{height:14px;background:url(../images/notch-green.png) top center no-repeat;}
.blueTip{}
.blueTip .content{width:310px;padding:10px;border:6px solid #36a4d9;-moz-border-radius:5px;-webkit-border-radius:5px;background:#90d8f0;color:#020202;}
.blueTip .bottom{height:14px;background:url(../images/notch-blue.png) top center no-repeat;}
.purpleTip{}
.purpleTip .content{width:310px;padding:10px;border:6px solid #8671de;-moz-border-radius:5px;-webkit-border-radius:5px;background:#a290f0;color:#020202;}
.purpleTip .bottom{height:14px;background:url(../images/notch-purple.png) top center no-repeat;}
.darkTip{}
.darkTip .content{width:310px;padding:10px;border:6px solid #303030;-moz-border-radius:5px;-webkit-border-radius:5px;background:#505050;color:#f8f8f8;}
.darkTip .bottom{height:14px;background:url(../images/notch-dark.png) top center no-repeat;}
附件:下载该文件资源,减少时间成本(增值服务)
留言
该资源可下载
File Source
.rar
60.46 KB
jquery特效4
最新结算
jquery虚拟键盘中文打字效果js代码
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
jquery虚拟键盘中文打字效果js代码
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
HTML5实现CSS滤镜图片切换特效代码
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
jQuery头像裁剪插件cropbox js代码
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
jQuery头像裁剪插件cropbox js代码
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
CSS3制作3D图片立方体旋转特效
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
CSS3制作3D图片立方体旋转特效
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
CSS3制作3D图片立方体旋转特效
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
CSS3制作3D图片立方体旋转特效
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
jQuery+css3实现信封效果
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
我们力求给您提供有用的文章,再此基础上,会附加营收资源,不做任何广告,让平台可以更好发展 若您发现您的权利被侵害,或使用了您的版权,请发邮件联系 sunlifel@foxmail.com ggbig觉得 : 不提供源码的文章不是好文章
合作伙伴
联系我们
  • QQ:21499807
  • 邮箱:sunlifel@foxmail.com
  • QQ扫一扫加QQ
    QQ扫一扫
Copyright 2023-2024 ggbig.com·皖ICP备2023004211号-1
打赏文章