The example in this article describes jQuery’s implementation of a sliding window effect that imitates Microsoft’s homepage and senses mouse changes. Share it with everyone for your reference. The details are as follows:
This is a jQuery sliding window that imitates the Microsoft homepage and senses mouse changes. After the mouse is placed, the window will stretch to the left and return to its original state after the mouse is removed. I found it on the official Microsoft website. After looking at the code, I find it easy to take it off and don’t dare to keep it to myself.
The screenshot of the running effect is as follows:
The online demo address is as follows:
http://demo.jb51.net/js/2015/jquery-f-microsoft-web-nav-demo/
The specific code is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>jQuery仿微软首页感应鼠标变化的滑动窗口</title> <meta http-equiv="content-type" content="text/html;charset=gb2312"> <style type="text/css"> .box{width:100px;height:100px;position:absolute;right:0;color:#fff;} .box1{top:100px;background:#000;} .box2{top:250px;background:#333;} .box3{top:400px;background:#666;} .box4{top:550px;background:#999;} </style> <script type="text/javascript" src="jquery1.3.2.js"></script> </head> <body> <div class="box box1">应用</div> <div class="box box2">下载</div> <div class="box box3">Windows Phone</div> <div class="box box4">Office</div> <script type="text/javascript"> $('.box').each(function(){ $(this).hover(function(){ $(this).stop().animate({width:'150'},1000); },function(){ $(this).stop().animate({width:'100'},1000); }); }); </script> </body> </html>
I hope this article will be helpful to everyone’s jQuery programming.