2015百度logo特效

2015,祝福大家新年快乐,熬夜无聊,无意间逛百度发现logo特效,研究了一下,是合成所有的图片然后更改backgroung-position实现的,然后自己实现了一下

先上图看一下效果.

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5 <title>无标题文档</title>
 6 <style>
 7 #box{
 8     position: absolute;
 9     top: 0px;
10     left: 50%;
11     margin-left:-135px;
12     width: 270px;
13     height: 129px;
14     cursor: pointer;
15     background: url(http://www.baidu.com/img/logo_newyear_341c17435f0cc9b19cd14ad060e1acd9.png) -27540px 0px no-repeat;
16 }
17 </style>
18 </head>
19
20 <body>
21
22 <div id="box"></div>
23 <script src="http://libs.baidu.com/jquery/1.9.0/jquery.min.js"></script>
24 <script>
25 $(function (){
26     var x1 = 0,
27         x2 = -8100,
28         timer1 = null,
29         timer2 = null;
30
31     timer1 = setInterval(function (){
32         x1-=270;
33         console.log(x1);
34
35         $("#box").css("backgroundPosition",x1+"px 0px");
36
37         if(x1 <= -7830){//-7830 -8100
38             x1 = 0;
39         }
40     },50)
41
42
43     $("#box").click(function(){
44         clearInterval(timer1);
45         logoPlay();
46     })
47
48     var logoPlay = function (){
49         x2 = -8100;
50
51         clearInterval(timer2);
52         timer2 = setInterval(function (){
53             x2-=270;
54             console.log(x2);
55
56             $("#box").css("backgroundPosition",x2+"px 0px");
57
58             if(x2 <= -27540){
59                 clearInterval(timer2);
60             }
61         },50)
62     }
63
64 })
65 </script>
66 </body>
67 </html>

p.s: 2015 新的一年,希望自己快快成长

附件百度网盘链接地址:http://pan.baidu.com/s/1c0yB7mo

时间: 2024-08-08 22:44:40

2015百度logo特效的相关文章

数学 2015百度之星初赛2 HDOJ 5255 魔法因子

题目传送门 1 /* 2 数学:不会写,学习一下这种解题方式:) 3 思路:设符合条件的数的最高位是h,最低位是l,中间不变的部分为mid,由题意可得到下面的公式(这里对X乘上1e6用a表示,b表示1e6) 4 (h*power+l+mid)*a = (l*power+h+mid)*b 5 可推得:mid = ((h*power+l) * a - (l*power+h) * b) / (a - b); 6 所以可以枚举h,l然后求mid,注意mid的最低位一定是0,因为留出最低位加l或者h 7

贪心/数学 2015百度之星资格赛 1004 放盘子

题目传送门 1 /* 2 贪心:小度熊先在多边形中间放一个盘子,接下来无论来访者怎么放,小度熊都根据多边形中心与来访者的盘子对称着放就能获胜. 3 题目已经给出方法,就是能否把盘子放在多边形中间,那么和边心距比较 4 */ 5 #include <cstdio> 6 #include <algorithm> 7 #include <cmath> 8 #include <cstring> 9 using namespace std; 10 11 const i

找规律 2015百度之星资格赛 1001 大搬家

题目传送门 1 /* 2 找规律:题目真心读不懂,排列组合的题目 3 */ 4 #include <cstdio> 5 #include <iostream> 6 #include <algorithm> 7 #include <cstring> 8 using namespace std; 9 10 typedef long long ll; 11 12 const int MAXN = 1e6 + 10; 13 const int INF = 0x3f3

模拟 2015百度之星资格赛 1003 IP聚合

题目传送门 1 /* 2 模拟水题,排序后找出重复的ip就可以了 3 */ 4 #include <cstdio> 5 #include <iostream> 6 #include <algorithm> 7 #include <cstring> 8 #include <string> 9 #include <cmath> 10 using namespace std; 11 12 const int MAXN = 1e3 + 10;

LIS 2015百度之星初赛2 HDOJ 5256 序列变换

题目传送门 1 /* 2 LIS(非严格):首先我想到了LIS,然而总觉得有点不对:每个数先减去它的下标,防止下面的情况发生:(转载) 3 加入序列是1,2,2,2,3,这样求上升子序列是3,也就是要修改2个,但是中间的两个2,变化范围又不能超过(1,3) 4 那么这样求的也就不对,但是减掉之后,相当于给中间重复的数留下了修改的空间 5 解释下为什么可以减而保持正确性:因为题目所求时严格递增,假设是2,3, 4,那么变成1, 1, 1,所以在LIS里非严格递增就可以了 6 这也是为什么要在upp

字符串处理 2015百度之星资格赛 1002 列变位法解密

题目传送门 1 /* 2 字符串处理:要求解码,然而二维数组开不下,可以直接输出 3 只要在余数的地方判断一下就行了,vector的效率不高 4 另外:感觉麻烦的地方应该纸上写写就清楚了 5 */ 6 #include <cstdio> 7 #include <iostream> 8 #include <algorithm> 9 #include <cstring> 10 #include <string> 11 #include <cma

二分搜索 2015百度之星初赛1 1003 序列变换

题目传送门 1 /* 2 二分搜索:在0-1e6的范围找到最小的max (ai - bi),也就是使得p + 1 <= a[i] + c or a[i] - c 3 比赛时以为是贪心,榨干智商也想不出来:( 4 */ 5 #include <cstdio> 6 #include <algorithm> 7 #include <cstring> 8 #include <cmath> 9 #include <iostream> 10 using

二分查找 2015百度之星初赛1 1001 超级赛亚ACMer

题目传送门 1 /* 2 二分找到不大于m的最大的数,记做p,只要a[p] + k <= a[p+1]就继续 3 注意:特判一下当没有比m小的数的情况:) 4 */ 5 #include <cstdio> 6 #include <cstring> 7 #include <cmath> 8 #include <algorithm> 9 using namespace std; 10 11 typedef long long ll; 12 13 const

BFS 2015百度之星初赛2 HDOJ 5254 棋盘占领

题目传送门 1 /* 2 BFS:先把1的入队,每个1和它相邻的组合后看看能不能使0变1,若有则添加入队,change函数返回改变了多少个0 3 注意:结果还要加上原来占领的 4 */ 5 #include <cstdio> 6 #include <algorithm> 7 #include <cstring> 8 #include <cmath> 9 #include <vector> 10 #include <queue> 11