结合jQuery+CSS3的酷炫特效

版权:原创 更新时间:1年以上
[该文章底部包含文件资源,可根据自己情况,决定是否下载资源使用,时间>金钱,如有需要,立即查看资源]

以下是 结合jQuery+CSS3的酷炫特效 的示例演示效果:

当前平台(PC电脑)
  • 平台:

部分效果截图:

结合jQuery+CSS3的酷炫特效

HTML代码(index.html):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
	<title>abc</title>
	<link rel="stylesheet" type="text/css" href="css/style.css"/>
	<script type="text/javascript" src="js/jquery-3.4.1.js"></script>
	<script type="text/javascript" src="js/script.js"></script>
	<script type="text/javascript" src="js/jquery-css-transform.js"></script>
	<script type="text/javascript" src="js/jquery-animate-css-rotate-scale.js"></script>
	<script type="text/javascript" src="js/jquery.easing.1.3.js"></script>
</head>
<body>
<div id="wrapper">
	<h1>jQuery DJ Chinaz<small>Useless CSS3 and jQuery fun</small></h1>
	<div id="content">
		<div class="center">
			<p id="playbutton"><img src="images/btn-play.png" alt="Play" id="playbtn" /></p>
		</div>
		<div id="dj">
			<div class="needle" id="needle1"></div>
			<div class="vinyl" id="vinyl1"></div>
			<div class="needle" id="needle2"></div>
			<div class="vinyl" id="vinyl2"></div>
			<div id="buttons">
				<div id="leftbtns">
					<div id="slowbutton1"><img src="images/btn-slow.png" alt="Slow" /></div>
					<div id="speedbutton1"><img src="images/btn-fast.png" alt="Fast" /></div>
				</div>
				<div id="rightbtns">
					<div id="slowbutton2"><img src="images/btn-slow.png" alt="Slow" /></div>	
					<div id="speedbutton2"><img src="images/btn-fast.png" alt="Fast" /></div>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
</html>

JS代码(script.js):

/** Author:Marco Kuiper (http://www.marcofolio.net/)*/
google.load("jquery","1.3.1");
	google.setOnLoadCallback(function(){
	// Variable to store if the records are spinningvar playing = false;
	// Variable to store if the mouse is down (to enable scratching)var mousedown = false;
	// Function to be called when the play button is clicked.// It changes from "play" to "pause" when records are spinning// and starts both the vinyls.$("#playbutton").click(function(){
	checkButtons();
	if(playing){
	// Pause$("#playbtn").attr("src","images/btn-play.png");
	playing = false;
	$(".vinyl").each(function(){
	// Clear the interval from the vinyl// to stop spinningvar intervalHandle = $(this).data('intervalHandle');
	clearInterval(intervalHandle);
	$(this).css({
	'cursor':'default'}
).stop().animate({
	rotate:'+=40deg'}
,800,'easeOutCubic');
}
);
}
else{
	// Play$("#playbtn").attr("src","images/btn-pause.png");
	playing = true;
	$(".vinyl").each(function(){
	$(this).css({
	'cursor':'move'}
).data('rotationAngle',10);
	startSpinning($(this));
}
);
}
}
);
	// Handle the "mouseDown" to enable scratching// We can't combine "mouseDown" with "mouseMove",so we'll need// to set a boolean (mousedown).// We're also clearing the intervals to prevent spinning$(".vinyl").mousedown(function(e){
	var intervalHandle = $(this).data('intervalHandle');
	clearInterval(intervalHandle);
	mousedown = true;
}
).mouseup(function(){
	mousedown = false;
	if(playing){
	startSpinning($(this));
}
}
);
	// When mousedown is true and the records are playing,// we can scratch the vinyls. This is where the code can be improved,// since we only register X-movement$(".vinyl").mousemove(function(e){
	if(mousedown && playing){
	var intervalHandle = $(this).data('intervalHandle');
	clearInterval(intervalHandle);
	$(this).rotate(e.pageX % 360);
}
}
);
	// Handlers for each speed button (slow or faster)$("#speedbutton1").click(function(){
	if($(this).data('isEnabled')){
	$("#vinyl1").data('rotationAngle',$("#vinyl1").data('rotationAngle') + 10);
}
checkButtons();
}
);
	$("#slowbutton1").click(function(){
	if($(this).data('isEnabled')){
	$("#vinyl1").data('rotationAngle',$("#vinyl1").data('rotationAngle') - 10);
}
checkButtons();
}
);
	$("#speedbutton2").click(function(){
	if($(this).data('isEnabled')){
	$("#vinyl2").data('rotationAngle',$("#vinyl2").data('rotationAngle') + 10);
}
checkButtons();
}
);
	$("#slowbutton2").click(function(){
	if($(this).data('isEnabled')){
	$("#vinyl2").data('rotationAngle',$("#vinyl2").data('rotationAngle') - 10);
}
checkButtons();
}
);
	/*** Start spinning those vinyls by the given element. Set an interval to keep the vinyl spinning* and attach it to the element to keep a reference for clearing later.**/
function startSpinning(element){
	element.stop().animate({
	rotate:'+=40deg'}
,800,'easeInCubic',function(){
	var intervalHandle = setInterval( function (){
	element.animate({
	rotate:'+=' + element.data('rotationAngle') + 'deg'}
,0);
}
,25);
	element.data('intervalHandle',intervalHandle);
}
);
}
/*** Check if the buttons needs to be changed**/
function checkButtons(){
	if($("#vinyl1").data('rotationAngle') == 0){
	$("#slowbutton1").data('isEnabled',false).children().attr("src","images/btn-slow-dis.png");
}
else{
	$("#slowbutton1").data('isEnabled',true).children().attr("src","images/btn-slow.png");
}
if($("#vinyl1").data('rotationAngle') == 50){
	$("#speedbutton1").data('isEnabled',false).children().attr("src","images/btn-fast-dis.png");
}
else{
	$("#speedbutton1").data('isEnabled',true).children().attr("src","images/btn-fast.png");
}
if($("#vinyl2").data('rotationAngle') == 0){
	$("#slowbutton2").data('isEnabled',false).children().attr("src","images/btn-slow-dis.png");
}
else{
	$("#slowbutton2").data('isEnabled',true).children().attr("src","images/btn-slow.png");
}
if($("#vinyl2").data('rotationAngle') == 50){
	$("#speedbutton2").data('isEnabled',false).children().attr("src","images/btn-fast-dis.png");
}
else{
	$("#speedbutton2").data('isEnabled',true).children().attr("src","images/btn-fast.png");
}
}
}
);
	

CSS代码(style.css):

/* __ _ _ _ / _| | (_) | | _ __ ___ __ _ _ __ ___ ___ | |_ ___ | |_ ___ _ __ ___| |_| '_ ` _ \ / _` | '__/ __/ _ \| _/ _ \| | |/ _ \ | '_ \ / _ \ __|| | | | | | (_| | | | (_| (_) | || (_) | | | (_) || | | | __/ |_|_| |_| |_|\__,_|_| \___\___/|_| \___/|_|_|\___(_)_| |_|\___|\__|*/
/* BASIC RESET */
ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,body,html,p,blockquote,fieldset,input{margin:0;padding:0;}
/* HTML ELEMENTS */
body{background-image:url("../images/wood_bg.jpg");}
h1{font:bold 65px/60px Helvetica,Arial,Sans-serif;text-align:center;color:#eee;text-shadow:0px 2px 6px #333;}
h1 small{font-size:20px;text-transform:uppercase;letter-spacing:14px;display:block;color:#ccc;}
h2 a{display:block;text-decoration:none;margin:0 0 30px 0;font:italic 45px Georgia,Times,Serif;text-align:center;color:#bfe1f1;text-shadow:0px 2px 6px #333;}
h2 a:hover{color:#90bcd0;}
/* COMMON CLASSES */
.break{clear:both;}
/* WRAPPER */
#wrapper{width:800px;margin:40px auto;}
/* CONTENT */
#content{}
/* DJ */
#dj{width:760px;margin:0 auto;}
.center{margin:0 auto;width:128px;}
#playbutton{text-align:center;cursor:pointer;width:128px;}
.vinyl{width:370px;height:370px;float:left;margin:0 5px;}
#vinyl1{background-image:url("../images/vinyl1.png");}
#vinyl2{background-image:url("../images/vinyl2.png");}
.needle{width:50px;height:76px;position:absolute;background-image:url("../images/needle.png");z-index:99;}
#needle1{margin-left:300px;}
#needle2{margin-left:680px;}
#buttons{z-index:9999;clear:both;}
#buttons img{cursor:pointer;}
#buttons div{float:left;margin-top:25px;}
#leftbtns{margin-left:60px;}
#rightbtns{margin-left:120px;}
附件:下载该文件资源,减少时间成本(增值服务)
留言
该资源可下载
File Source
.rar
541.56 KB
Html CSS3特效
最新结算
股权转让协议意向书模板
类型: .docx 金额: CNY 2.23¥ 状态: 待结算 详细>
股权转让协议意向书模板
类型: .docx 金额: CNY 0.28¥ 状态: 待结算 详细>
CSS3图片向上3D翻转渐隐消失特效
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
CSS3图片向上3D翻转渐隐消失特效
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
.net c# 将金额转人名币大写金额
类型: .rar 金额: CNY 2.39¥ 状态: 待结算 详细>
.net c# 将金额转人名币大写金额
类型: .rar 金额: CNY 0.3¥ 状态: 待结算 详细>
合伙退伙协议书范本模板
类型: .doc 金额: CNY 2.23¥ 状态: 待结算 详细>
合伙退伙协议书范本模板
类型: .doc 金额: CNY 0.28¥ 状态: 待结算 详细>
合伙退伙协议书范本模板
类型: .doc 金额: CNY 2.23¥ 状态: 待结算 详细>
合伙退伙协议书范本模板
类型: .doc 金额: CNY 0.28¥ 状态: 待结算 详细>
我们力求给您提供有用的文章,再此基础上,会附加营收资源,不做任何广告,让平台可以更好发展 若您发现您的权利被侵害,或使用了您的版权,请发邮件联系 sunlifel@foxmail.com ggbig觉得 : 不提供源码的文章不是好文章
合作伙伴
联系我们
  • QQ:21499807
  • 邮箱:sunlifel@foxmail.com
  • QQ扫一扫加QQ
    QQ扫一扫
Copyright 2023-2024 ggbig.com·皖ICP备2023004211号-1
打赏文章