javascript笔记:拷贝出腾讯微博关于London2012奥运会的拉绳开关的网页特效

本文主要是介绍javascript笔记:拷贝出腾讯微博关于London2012奥运会的拉绳开关的网页特效,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

  奥运会正在进行中,各大网站都因为这盛会有所改版或者是拿出了自己的新的页面特效。其中最牛叉的还是谷歌,如下图:

  可以用键盘控制的小游戏,看看它的源码:

<div id="hplogo" tabindex="0" dir="ltr" aria-label="跨栏" style="cursor: pointer;">
<canvas style="position: absolute;" height="207" width="530"></canvas>
.....

  canvas,html5....,拷贝它的代码还是有点难度了。

  但是我在国外的网站里还是发现了一个我感兴趣的特效,就是腾讯微博里的"拉绳开关"的换肤效果,这个比较简单,我把代码“抠 ”了出来。

  

  首先介绍小这个网页特效的效果,点击“London 2012”吊环图标,图标会下拉绳,释放鼠标后,页面背景会换成中国奥运军团的图 片,此时吊环下方,会有一个“还原”按钮,点击“还原”按钮,背景恢复到原来背景,继续点击拉绳吊环,背景图片会在不同的 奥运图片间切换,鼠标移到拉绳上方,鼠标变成剪刀样式,点击,吊环会以自由落体的方式坠落,最后消失。

  以上效果我都拷贝出来了,还是比较简单的,源码如下:

  首先还是目录结构:

  main.css的代码:

body {background-color:#999;color: #333333;font: 12px/1.75 Tahoma,Arial,sans-serif;
}
body {background:url(../images/wrapbg_v0.0.1.jpg) no-repeat scroll center top #73CFF1;color: #333333;font: 12px/1.75 Tahoma,Arial,sans-serif;height: 100%;
}
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, input, textarea, p, blockquote, th, td {margin: 0;padding: 0;
}
.nv_toogle_w {height: 0;margin: 0 auto;position: relative;width: 960px;
}
a, .c_tx {text-decoration: none;
}
a, .c_tx {color: #006A92;
}
.nv_toggle_btn, .nv_arrow_wpd, .nv_arrow_lab, .nv_arrow_message {background:url(../images/guide_icon.png) no-repeat scroll 0 0 transparent;
}
.nv_toggle_btn {background-position: -195px 0;cursor: pointer;display: block;height: 111px;position: absolute;right: -31px;text-indent: -9999px;top: -35px;width: 23px;z-index: 5;
}
.nv_toggle_btn_oly2012 {background: url("../images/nv_toggle_btn_oly2012.png") no-repeat scroll 0 0 transparent;height: 206px;right: -44px;top: -73px;width: 29px;
}
.headWrap a {color: #C9C9C9;
}
.headWrap a:hover {text-decoration: none;
}
.nv_toggle_btn span {display: block;
}
.nv_toggle_reset {color: #FECCF3 !important;position: absolute;right: -43px;top: 138px;
}
.nv_toggle_reset, .nv_toggle_reset span, .nv_toggle_reset b {display: block;height: 26px;width: 27px;
}
.nv_toggle_reset span {cursor: pointer;line-height: 26px;position: relative;text-align: center;z-index: 5;
}
.nv_toggle_reset b {background: none repeat scroll 0 0 #E33194;left: 0;opacity: 0.63;position: absolute;top: 0;z-index: 0;
}
.nv_toggle_cut {cursor: url("http://mat1.gtimg.com/www/mb/images/cut_c.cur"), pointer;display: block;height: 19px;position: absolute;right: -44px;top: 0;width: 29px;z-index: 10;
}

  main.js的代码:

var picInd = 0;
$(document).ready(function() {$("#nv_toogle_w").bind("mousedown",function(){ $(this).animate({top:"20px"},"normal");});$("#nv_toogle_w").bind("mouseup",function(){getRandomNum();$("body").attr("class","");$("body").addClass("body" + picInd);$(this).animate({top:"0px"},"normal");$("#nv_toogle_w2").css("display","block");});$("#nv_toogle_w2").bind("click",function(){$("body").attr("class","");$("#nv_toogle_w2").css("display","none");});$("#nv_toggle_cut").bind("click",function(){$("#nv_toogle_w").animate({top:"300px"},"4000");$("a[boss='btnWideGuideBtn']").animate({opacity:"0"},"3000");$("#nv_toogle_w2").css("display","none").delay(6999);});
});function getRandomNum(){while(true){var curInd = Math.floor(Math.random() * 8 + 1);if (picInd != 0 || picInd != curInd){picInd = curInd;break;    }}
}

  qq01.html的代码:

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>QQ Study 01</title>
</head>
<script type="text/javascript" src="js/jquery-1.7.1.js"></script>
<script type="text/javascript" src="js/main.js"></script>
<link type="text/css" rel="stylesheet" href="css/main.css" />
<style type="text/css">
.body1{background:url(images/bg/ldyx.jpg) no-repeat fixed center top #EFEFEF;    
}
.body2{background: url(images/bg/aycg_120802.jpg) no-repeat fixed center top #000000;
}
.body3{background: url(images/bg/jqsc.jpg) no-repeat fixed center top #000000;
}
.body4{background: url(images/bg/bg2.jpg) no-repeat fixed center top #1D1D1D;
}
.body5{background: url(images/bg/bg3.jpg) no-repeat fixed center top #1D1D1D;
}
.body6{background: url(images/bg/bg4.jpg) no-repeat fixed center top #1D1D1D;
}
.body7{background: url(images/bg/mlld.jpg) no-repeat fixed center top #429FDE;
}
.body8{background: url(images/bg/bg.jpg) no-repeat fixed center top #000000;
}
</style>
<body><div class="nv_head_wrap"><div title="拉一下换肤" style="top: 0px;" id="nv_toogle_w" class="nv_toogle_w"><a boss="btnWideGuideBtn" class="nv_toggle_btn nv_toggle_btn_oly2012"href="#"><span>new</span></a></div><div style="position:relative" class="nv_toogle_w"><a id="nv_toogle_w2" style="display: none;" class="nv_toggle_reset" href="#"><span>还原</span><b></b></a><a id="nv_toggle_cut" class="nv_toggle_cut" title="永久关闭此功能" href="#"></a></div><div></div></div>
</body>
</html>

下载链接:

http://files.cnblogs.com/sharpxiajun/myQQ.zip

 

 

 

 

 

 

 

这篇关于javascript笔记:拷贝出腾讯微博关于London2012奥运会的拉绳开关的网页特效的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/164855

相关文章

一文详解SpringBoot中控制器的动态注册与卸载

《一文详解SpringBoot中控制器的动态注册与卸载》在项目开发中,通过动态注册和卸载控制器功能,可以根据业务场景和项目需要实现功能的动态增加、删除,提高系统的灵活性和可扩展性,下面我们就来看看Sp... 目录项目结构1. 创建 Spring Boot 启动类2. 创建一个测试控制器3. 创建动态控制器注

Java操作Word文档的全面指南

《Java操作Word文档的全面指南》在Java开发中,操作Word文档是常见的业务需求,广泛应用于合同生成、报表输出、通知发布、法律文书生成、病历模板填写等场景,本文将全面介绍Java操作Word文... 目录简介段落页头与页脚页码表格图片批注文本框目录图表简介Word编程最重要的类是org.apach

Spring Boot中WebSocket常用使用方法详解

《SpringBoot中WebSocket常用使用方法详解》本文从WebSocket的基础概念出发,详细介绍了SpringBoot集成WebSocket的步骤,并重点讲解了常用的使用方法,包括简单消... 目录一、WebSocket基础概念1.1 什么是WebSocket1.2 WebSocket与HTTP

SpringBoot+Docker+Graylog 如何让错误自动报警

《SpringBoot+Docker+Graylog如何让错误自动报警》SpringBoot默认使用SLF4J与Logback,支持多日志级别和配置方式,可输出到控制台、文件及远程服务器,集成ELK... 目录01 Spring Boot 默认日志框架解析02 Spring Boot 日志级别详解03 Sp

java中反射Reflection的4个作用详解

《java中反射Reflection的4个作用详解》反射Reflection是Java等编程语言中的一个重要特性,它允许程序在运行时进行自我检查和对内部成员(如字段、方法、类等)的操作,本文将详细介绍... 目录作用1、在运行时判断任意一个对象所属的类作用2、在运行时构造任意一个类的对象作用3、在运行时判断

java如何解压zip压缩包

《java如何解压zip压缩包》:本文主要介绍java如何解压zip压缩包问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Java解压zip压缩包实例代码结果如下总结java解压zip压缩包坐在旁边的小伙伴问我怎么用 java 将服务器上的压缩文件解压出来,

SpringBoot中SM2公钥加密、私钥解密的实现示例详解

《SpringBoot中SM2公钥加密、私钥解密的实现示例详解》本文介绍了如何在SpringBoot项目中实现SM2公钥加密和私钥解密的功能,通过使用Hutool库和BouncyCastle依赖,简化... 目录一、前言1、加密信息(示例)2、加密结果(示例)二、实现代码1、yml文件配置2、创建SM2工具

Spring WebFlux 与 WebClient 使用指南及最佳实践

《SpringWebFlux与WebClient使用指南及最佳实践》WebClient是SpringWebFlux模块提供的非阻塞、响应式HTTP客户端,基于ProjectReactor实现,... 目录Spring WebFlux 与 WebClient 使用指南1. WebClient 概述2. 核心依

Spring Boot @RestControllerAdvice全局异常处理最佳实践

《SpringBoot@RestControllerAdvice全局异常处理最佳实践》本文详解SpringBoot中通过@RestControllerAdvice实现全局异常处理,强调代码复用、统... 目录前言一、为什么要使用全局异常处理?二、核心注解解析1. @RestControllerAdvice2

Spring IoC 容器的使用详解(最新整理)

《SpringIoC容器的使用详解(最新整理)》文章介绍了Spring框架中的应用分层思想与IoC容器原理,通过分层解耦业务逻辑、数据访问等模块,IoC容器利用@Component注解管理Bean... 目录1. 应用分层2. IoC 的介绍3. IoC 容器的使用3.1. bean 的存储3.2. 方法注