Advertisement
octomoosey

moose keyframes

Aug 9th, 2016
1,461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.71 KB | None | 0 0
  1. <!-- keyframes demo by octomoosey @ tumblr -->
  2.  
  3. <style>
  4. body {
  5. margin:0;
  6. background:#656565;}
  7.  
  8. #credit {
  9. z-index:8;
  10. bottom:-3px;
  11. right:3px;
  12. height:30px;
  13. width:30px;
  14. opacity:0.8;
  15. position:fixed;}
  16.  
  17. /* ---------------ANIMATION 1 -- BOUNCE EFFECT---------------*/
  18.  
  19. /* the first two sections of css are just setting up our object. you can set the positioning and any colours, backgrounds etc as usual! */
  20. .moose-animation{
  21. position:fixed;
  22. margin-left:10px;
  23. margin-top:10px;
  24. /* this is where we set up the animation for the object, there are several lines which seem to repeat the same information, but this is just for cross browser compatibility */
  25.  
  26. /* the next section picks apart the 3 lines needed to set up the animation and explains each. this is the duration, the iteration and the origin */
  27.  
  28. animation: bbounce linear 2.5s; /* this line links us to the keyframe name we set up. it also gives the total duration of the animation, if you want to make the animation slower, increase the time, for a quicker animation, decrease the time */
  29. animation-iteration-count: infinite; /* this makes sure the animation will continue to play, you can change this to a number if you only want the animation to play a certain number of times ( or to 1 if you only want it to play on page loading for example ) */
  30. transform-origin: 50% 50%; /* this just specifies that we want all transformations or effects to be centered on the object. you can change this if you want to pin the transition effect to a corner of your object */
  31.  
  32. /* Safari 4+, Android, Chrome */
  33. -webkit-animation: bbounce linear 2.5s;
  34. -webkit-animation-iteration-count: infinite;
  35. -webkit-transform-origin: 50% 50%;
  36.  
  37. /* Fx 5+ */
  38. -moz-animation: bbounce linear 2.5s;
  39. -moz-animation-iteration-count: infinite;
  40. -moz-transform-origin: 50% 50%;
  41.  
  42. /* Opera 12+ */
  43. -o-animation: bbounce linear 2.5s;
  44. -o-animation-iteration-count: infinite;
  45. -o-transform-origin: 50% 50%;
  46.  
  47. /* IE 10+, Fx 29+ */
  48. -ms-animation: bbounce linear 2.5s;
  49. -ms-animation-iteration-count: infinite;
  50. -ms-transform-origin: 50% 50%;}
  51.  
  52. /* in these examples i'm going to animate an image. this image could also be a link or the trigger for a hoverbox. you can animate pretty much any object, a piece of text, a whole block, a title, etc.*/
  53. .moose-animation img {
  54. height:30px;
  55. width:30px;
  56. border-radius:100%;
  57. padding:5px;
  58. border:1px solid #ffffff;
  59. background:#333333;}
  60.  
  61. /* this is my keyframe setup. i need to give it a name, in this case it's 'bbounce' - the name that is referred to in the css section above. i need to make sure that all of the browser extensions have the same name. we use percentages to specify at which point in the animation certain states have to be achieved. in the first css section above we specified the duration as 2.5 seconds. so at 0 seconds ( 0% ) the animation will begin. by 50% ( halfway through ) the object will have moved 10px down and by 100% ( the 2.5 second point ) it will have returned to the starting position. you can also use negative values to get things to move to the left or up. try out different settings to see how things move! the command 'transform:translate' will change position. */
  62. @keyframes bbounce{
  63. 0% {transform:translate(0px,0px);}
  64. 50% {transform:translate(0px,10px);}
  65. 100% {transform:translate(0px, 0px);}
  66. }
  67.  
  68. @-moz-keyframes bbounce{
  69. 0% {-moz-transform:translate(0px,0px);}
  70. 50% {-moz-transform:translate(0px,10px);}
  71. 100% {-moz-transform:translate(0px,0px);}
  72. }
  73.  
  74. @-webkit-keyframes bbounce {
  75. 0% {-webkit-transform:translate(0px,0px);}
  76. 50% {-webkit-transform:translate(0px,10px);}
  77. 100% {-webkit-transform:translate(0px,0px);}
  78. }
  79.  
  80. @-o-keyframes bbounce {
  81. 0% {-o-transform:translate(0px,0px);}
  82. 50% {-o-transform:translate(0px,10px);}
  83. 100% {-o-transform:translate(0px,0px);}
  84. }
  85.  
  86. @-ms-keyframes bbounce {
  87. 0% {-ms-transform:translate(0px,0px);}
  88. 50% {-ms-transform:translate(0px,10px);}
  89. 100% {-ms-transform:translate(0px,0px);}
  90. }
  91.  
  92. /* ---------------ANIMATION 2 -- FADE/OPACITY EFFECT---------------*/
  93.  
  94. /* the setup is the same as above, again specifying the duration of the animation and making sure to refer to the keyframes setup by name, in this case 'o-opacity' and covering all browser options */
  95. .squirrel-animation{
  96. position:fixed;
  97. margin-left:60px;
  98. margin-top:10px;
  99. animation: o-opacity linear 3.5s;
  100. animation-iteration-count: infinite;
  101. transform-origin: 50% 50%;
  102. -webkit-animation: o-opacity linear 3.5s;
  103. -webkit-animation-iteration-count: infinite;
  104. -webkit-transform-origin: 50% 50%;
  105. -moz-animation: o-opacity linear 3.5s;
  106. -moz-animation-iteration-count: infinite;
  107. -moz-transform-origin: 50% 50%;
  108. -o-animation: o-opacity linear 3.5s;
  109. -o-animation-iteration-count: infinite;
  110. -o-transform-origin: 50% 50%;
  111. -ms-animation: o-opacity linear 3.5s;
  112. -ms-animation-iteration-count: infinite;
  113. -ms-transform-origin: 50% 50%;}
  114.  
  115. .squirrel-animation img {
  116. height:30px;
  117. width:30px;
  118. border-radius:100%;
  119. padding:5px;
  120. border:1px solid #ffffff;
  121. background:#333333;}
  122.  
  123. /* again as above, we name sure our keyframe setup name matches the one referred to in our css for the object. in this case the % values relate to the opacity of the object, starting at opacity 1, with it fading to 0.1 at 50% of the animation and back to opacity 1 at 100% */
  124.  
  125. @keyframes o-opacity{
  126. 0% {opacity:1;}
  127. 50% {opacity:0.1;}
  128. 100% {opacity:1;}}
  129. }
  130.  
  131. @-moz-keyframes o-opacity{
  132. 0% {opacity:1;}
  133. 50% {opacity:0.1;}
  134. 100% {opacity:1;}
  135. }
  136.  
  137. @-webkit-keyframes o-opacity {
  138. 0% {opacity:1;}
  139. 50% {opacity:0.1;}
  140. 100% {opacity:1;}
  141. }
  142.  
  143. @-o-keyframes o-opacity {
  144. 0% {opacity:1;}
  145. 50% {opacity:0.1;}
  146. 100% {opacity:1;}
  147. }
  148.  
  149. @-ms-keyframes o-opacity {
  150. 0% {opacity:1;}
  151. 50% {opacity:0.1;}
  152. 100% {opacity:1;}
  153. }
  154.  
  155. /* ---------------ANIMATION 3 -- COMBINED EFFECT---------------*/
  156.  
  157. /* the setup is the same as above, again specifying the duration of the animation and making sure to refer to the keyframes setup by name, in this case 'allthings' and covering all browser options */
  158.  
  159. .tiger-animation{
  160. position:fixed;
  161. margin-left:110px;
  162. margin-top:10px;
  163. animation: allthings linear 3.5s;
  164. animation-iteration-count: infinite;
  165. transform-origin: 50% 50%;
  166. -webkit-animation: allthings linear 3.5s;
  167. -webkit-animation-iteration-count: infinite;
  168. -webkit-transform-origin: 50% 50%;
  169. -moz-animation: allthings linear 3.5s;
  170. -moz-animation-iteration-count: infinite;
  171. -moz-transform-origin: 50% 50%;
  172. -o-animation: allthings linear 3.5s;
  173. -o-animation-iteration-count: infinite;
  174. -o-transform-origin: 50% 50%;
  175. -ms-animation: allthings linear 3.5s;
  176. -ms-animation-iteration-count: infinite;
  177. -ms-transform-origin: 50% 50%;}
  178.  
  179. .tiger-animation img {
  180. height:30px;
  181. width:30px;
  182. border-radius:100%;
  183. padding:5px;
  184. border:1px solid #ffffff;
  185. background:#333333;}
  186.  
  187. /* ---------------ANIMATION 3 -- COMBINED EFFECT---------------*/
  188.  
  189. /* this time we have more divisions in our keyframes, settings at 0%, 25%, 50%, 75% and 100% - remember if you want a smooth animation your 0% and your 100% should make sure the object returns to the same position! this example has both opacity changes, size changes ( scale ) and a rotation, so as the object moves, it will shrink, fade out and turn! the command 'transform:rotate' will rotate or turn your object, the command 'transform:scale' will change it's size. make sure to scale both x and y values to stop any distortion. if we have more than one transformation we can combine them into one line - so in this case we just give the rotate and the scale commands for each % value in one line.*/
  190. @keyframes allthings{
  191. 0% {opacity:1;
  192. transform: rotate(0deg) scaleX(1.00) scaleY(1.00);}
  193. 25% {opacity:0.5;
  194. transform: rotate(90deg) scaleX(0.50) scaleY(0.50);}
  195. 50% {opacity:0.1;
  196. transform: rotate(180deg) scaleX(0.20) scaleY(0.20);}
  197. 75% {opacity:0.5;
  198. transform: rotate(270deg) scaleX(0.50) scaleY(0.50);}
  199. 100% {opacity:1;
  200. transform: rotate(360deg) scaleX(1.00) scaleY(1.00);}
  201. }
  202.  
  203. @-moz-keyframes allthings{
  204. 0% {opacity:1;
  205. -moz-transform: rotate(0deg) scaleX(1.00) scaleY(1.00);}
  206. 25% {opacity:0.5;
  207. -moz-transform: rotate(90deg) scaleX(0.50) scaleY(0.50);}
  208. 50% {opacity:0.1;
  209. -moz-transform: rotate(180deg) scaleX(0.20) scaleY(0.20);}
  210. 75% {opacity:0.5;
  211. -moz-transform: rotate(270deg) scaleX(0.50) scaleY(0.50);}
  212. 100% {opacity:1;
  213. -moz-transform: rotate(360deg) scaleX(1.00) scaleY(1.00);}
  214. }
  215.  
  216. @-webkit-keyframes allthings {
  217. 0% {opacity:1;
  218. -webkit-transform: rotate(0deg) scaleX(1.00) scaleY(1.00);}
  219. 25% {opacity:0.5;
  220. -webkit-transform: rotate(90deg) scaleX(0.50) scaleY(0.50);}
  221. 50% {opacity:0.1;
  222. -webkit-transform: rotate(180deg) scaleX(0.20) scaleY(0.20);}
  223. 75% {opacity:0.5;
  224. -webkit-transform: rotate(270deg) scaleX(0.50) scaleY(0.50);}
  225. 100% {opacity:1;
  226. -webkit-transform: rotate(360deg) scaleX(1.00) scaleY(1.00);}
  227. }
  228.  
  229. @-o-keyframes allthings {
  230. 0% {opacity:1;
  231. -o-transform: rotate(0deg) scaleX(1.00) scaleY(1.00);}
  232. 25% {opacity:0.5;
  233. -o-transform: rotate(90deg) scaleX(0.50) scaleY(0.50);}
  234. 50% {opacity:0.1;
  235. -o-transform: rotate(180deg) scaleX(0.20) scaleY(0.20);}
  236. 75% {opacity:0.5;
  237. -o-transform: rotate(270deg) scaleX(0.50) scaleY(0.50);}
  238. 100% {opacity:1;
  239. -o-transform: rotate(360deg) scaleX(1.00) scaleY(1.00);}
  240. }
  241.  
  242. @-ms-keyframes allthings {
  243. 0% {opacity:1;
  244. -ms-transform: rotate(0deg) scaleX(1.00) scaleY(1.00);}
  245. 25% {opacity:0.5;
  246. -ms-transform: rotate(90deg) scaleX(0.50) scaleY(0.50);}
  247. 50% {opacity:0.1;
  248. -ms-transform: rotate(180deg) scaleX(0.20) scaleY(0.20);}
  249. 75% {opacity:0.5;
  250. -ms-transform: rotate(270deg) scaleX(0.50) scaleY(0.50);}
  251. 100% {opacity:1;
  252. -ms-transform: rotate(360deg) scaleX(1.00) scaleY(1.00);}
  253. }
  254.  
  255. </style>
  256. <body>
  257. <div class="moose-animation"><img src="https://66.media.tumblr.com/f2bdd6badefd2b0a5f51cbe6dc7877e1/tumblr_inline_obdm0rUzOQ1ro20i7_540.jpg"></div>
  258.  
  259. <div class="squirrel-animation"><img src="https://66.media.tumblr.com/f2bdd6badefd2b0a5f51cbe6dc7877e1/tumblr_inline_obdm0rUzOQ1ro20i7_540.jpg"></div>
  260.  
  261. <div class="tiger-animation"><img src="https://66.media.tumblr.com/f2bdd6badefd2b0a5f51cbe6dc7877e1/tumblr_inline_obdm0rUzOQ1ro20i7_540.jpg"></div>
  262.  
  263. <div id="credit"><a href="https://octomoosey.tumblr.com/" title="theme by octomoosey"><img src="https://static.tumblr.com/uopakca/cwDo0y64u/octopus-24.png"></a></div>
  264.  
  265. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement