时间:2021-05-18
就不给大家多文字说明了。给大家梳理下关键步骤。
关键步骤:
1、引入js文件
<script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src='js/jquery.thoughtBubble.js'></script>2、在需要使用气泡效果的地方
<div id='mainContainer' class='container'><img src='ahout.JPG' id="thoughtBubble" alt='whats up?' /></div>3、使用气泡效果
<script type="text/javascript">$(window).ready( function() {$('#thoughtBubble').thoughtBubble({text: 'baby,I love you',font: 'avenir'});});4、这是jquery.thoughtBubblr.js代码
(function($) {$.fn.thoughtBubble = function( defaults ) {var settings = $.extend({backgroundColor: 'white',fontColor: 'black',width: '330px',height: '210px',fontSize: '15px',bubbleColor: 'white',speed: 125}, defaults ),getBubbleDiv = function( container ) {var offset = container.offset(),modifiedHeight = offset.top - parseInt( settings.height ),style = '"position: absolute; top:' + modifiedHeight + 'px; left:' + offset.left + 'px ; width:' + settings.width + '; height:' + settings.height + ';"',bubbleContainer = "<div class='bubble-holder' style=" + style + ">" + getMainBubble() + getBubbles() + "</div>";return bubbleContainer;},getMainBubble = function() {return '<div class="main-bubble-holder"><div class="bubble main-bubble">' + getText() + '</div></div>';},getText = function() {return '<span style="vertical-align: middle; color: ' + settings.fontColor + ';font-size: ' + settings.fontSize + '; font-family: ' + settings.font + '">' + settings.text + '</span>';},getBubbles = function() {return '<div class="sm-bubble-holder"><div class="bubble bubbleLg"></div><div class="bubble bubbleMd"></div><div class="bubble bubbleSm"></div></div>';},animate = function(){var bubbles = $(document).find('.bubble'),reversed = bubbles.get().reverse(),speed = settings.speed;$(reversed[0]).stop().animate({ opacity: 1}, speed, function() {$(reversed[1]).animate({ opacity: 1}, speed, function() {$(reversed[2]).animate({ opacity: 1}, speed, function() {$(reversed[3]).animate({ opacity: 1},speed);});});});},unanimate = function() {var bubbles = $(document).find('.bubble');bubbles.stop().animate({opacity: 0});},shiftDiv = function( container ) {var bubbleHolder = $(document).find('.bubble-holder'),previousPosition = container.offset().left;bubbleHolder.css('left', previousPosition);};return this.each( function() {var $this = $(this),container = getBubbleDiv( $this );$this.on('mouseenter', animate );$this.on('mouseout', unanimate );$(window).on('resize', shiftDiv.bind(this, $this) );return $this.parent().prepend(container);});};})(jQuery);以上给大家分享了js气泡效果的关键步骤,代码简单易懂,就没给写过多的文字说明,大家有疑问欢迎给我留言,小编会及时回复大家的,在此小编也非常感谢大家对网站的支持!
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
本文实例讲述了js由下向上不断上升冒气泡效果的方法。分享给大家供大家参考。具体实现方法如下:JS实现气泡从水中急速上升效果body{cursor:crossha
先发Canvas实现直播点赞气泡效果图:实现细节:1.JS:drawImage:function(data){[/align]varthat=thisvarp1
一款基于纯CSS的气泡提示框,整个提示框由箭头和矩形框组成,并且气泡提示框的箭头可以有不同的方向。在线预览源码下载实现的代码。css代码:CSSCode复制内容
js纯数字逐一停止显示效果的实现代码functionshowScore($ele,num,secand,pause){//second按照秒数,动画运行多少秒i
本文实例讲述了js实现点击切换TAB标签。分享给大家供大家参考。具体如下:这里演示的选项卡效果代码,无jq,纯JS来实现,灰色风格,没有怎么美化,或许看上去比较