JQuery/Javascript块缩放

Max*_*rai 1 javascript jquery scale effect

我有一些div块.我需要缩放它自己的大小.就像在MacOS停靠面板中一样,当图标悬停时.我可以这样做吗?

meo*_*meo 5

是的你可以:

HTML:

<div class="scaleMe">&nbsp</div>
Run Code Online (Sandbox Code Playgroud)

jQuery的:

$(function(){ /* makes sure your dom is ready */
   $('div.scaleMe').hover(function(){
                       $(this).stop(false, true).animate({width:'50px', height:'50px'}, 1000) /* makes the div big on hover, and .stop() makes sure the annimation is not looping*/
                    },function(){
                       $(this).stop(false, true).animate({width:'20px', height:'20px'}, 600) /* goes back to normal state */
                    })
})
Run Code Online (Sandbox Code Playgroud)

在这里你可以找到一个很好的例子,用jQuery制作的OSX这样的底座:http: //www.ndesign-studio.com/blog/css-dock-menu