Created
February 13, 2014 22:43
-
-
Save etrepum/8985465 to your computer and use it in GitHub Desktop.
Mission Bit Intro 04 - Animation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
More information about transforms and transitions: | |
CSS transforms: | |
* https://developer.mozilla.org/en-US/docs/Web/CSS/transform | |
CSS transitions: | |
* https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Using_CSS_transitions | |
*/ | |
.clickable { | |
cursor: pointer; | |
transition: 2s; | |
} | |
.box-1.clickable { | |
width: 200px; | |
height: 200px; | |
background-color: blue; | |
} | |
.box-1.clicked { | |
background-color: aquamarine; | |
transform: rotate(360deg); | |
} | |
.box-2.clickable { | |
width: 200px; | |
height: 200px; | |
background-color: #cccccc; | |
} | |
.box-2.clicked { | |
transform: rotate3d(-1, -1, 0, 720deg); | |
background-color: #333333; | |
transition: 4s; | |
} | |
h1.clickable { | |
transition: color 2s, margin-left 1s; | |
color: blue; | |
} | |
h1.clicked { | |
color: red; | |
margin-left: 100px; | |
} | |
.logo.clickable { | |
position: absolute; | |
width: 300px; | |
height: 300px; | |
margin-left: -300px; | |
margin-top: -300px; | |
left: 100%; | |
top: 300px; | |
} | |
.logo.clicked { | |
top: 100%; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script> | |
<link rel="stylesheet" href="animation.css"> | |
</head> | |
<body> | |
<h1 class="clickable">Click this!</h1> | |
<div class="box-1 clickable"></div> | |
<div class="box-2 clickable"></div> | |
<img class="logo clickable" src="mbit-logo.svg"> | |
<script src="animation.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jslint sloppy:true*/ | |
/*global $ */ | |
$('.clickable').on('click', function () { | |
$(this).toggleClass('clicked'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment