最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

jQuery实现网页抖动的菜单抖动效果_jquery

来源:动视网 责编:小采 时间:2020-11-27 21:41:46
文档

jQuery实现网页抖动的菜单抖动效果_jquery

jQuery实现网页抖动的菜单抖动效果_jquery:本文实例讲述了jQuery实现网页抖动的菜单抖动效果。分享给大家供大家参考。具体如下: 这里的jQuery抖动导航菜单效果,兼容IE7/8/9及其它主流浏览器,使用方法:先引入jQuery脚本库和jquery.shake.js文件,然后在需要的元素上调用shake( )方法,例如
推荐度:
导读jQuery实现网页抖动的菜单抖动效果_jquery:本文实例讲述了jQuery实现网页抖动的菜单抖动效果。分享给大家供大家参考。具体如下: 这里的jQuery抖动导航菜单效果,兼容IE7/8/9及其它主流浏览器,使用方法:先引入jQuery脚本库和jquery.shake.js文件,然后在需要的元素上调用shake( )方法,例如
 本文实例讲述了jQuery实现网页抖动的菜单抖动效果。分享给大家供大家参考。具体如下:

这里的jQuery抖动导航菜单效果,兼容IE7/8/9及其它主流浏览器,使用方法:先引入jQuery脚本库和jquery.shake.js文件,然后在需要的元素上调用shake( )方法,例如想使整个页面抖动,则这么写:$('body').shake( ),调用上述方法后,将鼠标移至指定的元素,该元素就会抖动。

运行效果截图如下:

具体代码如下:






jQuery抖动导航菜单效果


(function ($) {
$.fn.shake = function (s) {
 var t = { rangeX: 2, rangeY: 2, rangeRot: 1, rumbleSpeed: 10, rumbleEvent: 'hover', posX: 'left', posY: 'top' }, u = $.extend(t, s);
 return this.each(function () {
 var $obj = $(this)
 , f
 , g = u.rangeX * 2
 , h = u.rangeY * 2
 , i = u.rangeRot * 2
 , j = u.rumbleSpeed
 , k = $obj.css('position')
 , l = u.posX
 , m = u.posY
 , n
 , o
 , p
 , q = { 'position': k, '-webkit-transform': 'rotate(0deg)', '-moz-transform': 'rotate(0deg)', '-o-transform': 'rotate(0deg)', 'transform': 'rotate(0deg)' };
 if (l === 'left') {
 n = parseInt($obj.css('left'), 10)
 }
 if (l === 'right') {
 n = parseInt($obj.css('right'), 10)
 }
 if (m === 'top') {
 o = parseInt($obj.css('top'), 10)
 }
 if (m === 'bottom') {
 o = parseInt($obj.css('bottom'), 10)
 }
 function rumbler(a) {
 var b = Math.random()
 , c = Math.floor(Math.random() * (g + 1)) - g / 2
 , d = Math.floor(Math.random() * (h + 1)) - h / 2
 , e = Math.floor(Math.random() * (i + 1)) - i / 2;
 if (a.css('display') === 'inline') {
 p = true;
 a.css('display', 'inline-block')
 }
 if (c === 0 && g !== 0) {
 c = b < .5 ? 1 : -1;
 }
 if (d === 0 && h !== 0) {
 d = b < .5 ? 1 : -1;
 }
 if (k === 'absolute') {
 a.css({ 'position': 'absolute', '-webkit-transform': 'rotate(' + e + 'deg)', '-moz-transform': 'rotate(' + e + 'deg)', '-o-transform': 'rotate(' + e + 'deg)', 'transform': 'rotate(' + e + 'deg)' });
 a.css(l, n + c + 'px');
 a.css(m, o + d + 'px')
 }
 if (k === 'fixed') {
 a.css({ 'position': 'fixed', '-webkit-transform': 'rotate(' + e + 'deg)', '-moz-transform': 'rotate(' + e + 'deg)', '-o-transform': 'rotate(' + e + 'deg)', 'transform': 'rotate(' + e + 'deg)' });
 a.css(l, n + c + 'px');
 a.css(m, o + d + 'px')
 }
 if (k === 'static' || k === 'relative') {
 a.css({ 'position': 'relative', '-webkit-transform': 'rotate(' + e + 'deg)', '-moz-transform': 'rotate(' + e + 'deg)', '-o-transform': 'rotate(' + e + 'deg)', 'transform': 'rotate(' + e + 'deg)' });
 a.css(l, c + 'px');
 a.css(m, d + 'px')
 }
 }
 if (u.rumbleEvent === 'hover') {
 $obj.hover(function () {
 var a = $(this);
 f = setInterval(function () {
 rumbler(a)
 }, j)
 }, function () {
 var a = $(this);
 clearInterval(f);
 a.css(q);
 a.css(l, n + 'px');
 a.css(m, o + 'px');
 if (p === true) {
 a.css('display', 'inline')
 }
 });
 }
 if (u.rumbleEvent === 'click') {
 $obj.toggle(function () {
 var a = $(this);
 f = setInterval(function () {
 rumbler(a)
 }, j)
 }, function () {
 var a = $(this);
 clearInterval(f);
 a.css(q);
 a.css(l, n + 'px');
 a.css(m, o + 'px');
 if (p === true) {
 a.css('display', 'inline')
 }
 });
 }
 if (u.rumbleEvent === 'mousedown') {
 $obj.bind({
 mousedown: function () {
 var a = $(this);
 f = setInterval(function () {
 rumbler(a)
 }, j)
 }, mouseup: function () {
 var a = $(this);
 clearInterval(f);
 a.css(q);
 a.css(l, n + 'px');
 a.css(m, o + 'px');
 if (p === true) {
 a.css('display', 'inline')
 }
 }, mouseout: function () {
 var a = $(this);
 clearInterval(f);
 a.css(q);
 a.css(l, n + 'px');
 a.css(m, o + 'px');
 if (p === true) {
 a.css('display', 'inline')
 }
 }
 });
 }
 if (u.rumbleEvent === 'constant') {
 var r = $(this);
 f = setInterval(function () {
 rumbler(r)
 }, j);
 }
 });
 }
}(jQuery));



 
 
 
  • 首页
  • ASP
  • PHP
  • JSP
  • DELPHI
  • VC++
  • C#
  • VB
  • .NET
  • 将鼠标移动到导航条上查看效果

    希望本文所述对大家的jquery程序设计有所帮助。

    文档

    jQuery实现网页抖动的菜单抖动效果_jquery

    jQuery实现网页抖动的菜单抖动效果_jquery:本文实例讲述了jQuery实现网页抖动的菜单抖动效果。分享给大家供大家参考。具体如下: 这里的jQuery抖动导航菜单效果,兼容IE7/8/9及其它主流浏览器,使用方法:先引入jQuery脚本库和jquery.shake.js文件,然后在需要的元素上调用shake( )方法,例如
    推荐度:
    • 热门焦点

    最新推荐

    猜你喜欢

    热门推荐

    专题
    Top