123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <script src="js/modernizr.js"></script>
- <title>Box animation – CSS keyframe animations</title>
- <style>
- body {
- background-color: #663399;
- margin: 2em;
- }
- .logo {
- color: #fff;
- font-family: Helvetica Neue, Arial, sans-serif;
- font-size: 2em;
- margin: 1em 0;
- }
- .logo-box {
- margin-left: -.15em;
- }
- .logo-model {
- display: inline-block;
- font-weight: 400;
- opacity: .6;
- }
- /**
- * Note: we've simplified the prefixed syntax down to just using
- * the webkit-prefixed version (which covers most browsers in use today)
- * apart from the standard unprefixed syntax.
- */
- .box-outer {
- display: inline-block;
- -webkit-animation: shift 4.5s 1s steps(3, start) backwards;
- animation: shift 4.5s 1s steps(3, start) backwards;
- }
- .box-inner {
- display: inline-block;
- width: .74em;
- height: .74em;
- background-color: #fff;
- -webkit-animation: roll 1.5s 1s 3 linear backwards;
- animation: roll 1.5s 1s 3 linear backwards;
- -webkit-transform-origin: bottom right;
- transform-origin: bottom right;
- }
- /* for older webkit-based browsers: */
- @-webkit-keyframes roll {
- from {
- -webkit-transform: translateX(-100%);
- -webkit-animation-timing-function: ease-in-out;
- }
- 20% {
- -webkit-transform: translateX(-100%) skewX(15deg);
- }
- 28% {
- -webkit-transform: translateX(-100%) skewX(0deg);
- -webkit-animation-timing-function: ease-out;
- }
- 45% {
- -webkit-transform: translateX(-100%) skewX(-5deg) rotate(20deg) scaleY(1.1);
- -webkit-animation-timing-function: ease-in-out;
- }
- 50% {
- -webkit-transform: translateX(-100%) rotate(45deg) scaleY(1.1);
- -webkit-animation-timing-function: ease-in;
- }
- 60% {
- -webkit-transform: translateX(-100%) rotate(90deg);
- }
- 65% {
- -webkit-transform: translateX(-100%) rotate(90deg) skewY(10deg);
- }
- 70% {
- -webkit-transform: translateX(-100%) rotate(90deg) skewY(0deg);
- }
- 100% {
- -webkit-transform: translateX(-100%) rotate(90deg);
- }
- }
- /* standard syntax: */
- @keyframes roll {
- from {
- transform: translateX(-100%);
- animation-timing-function: ease-in-out;
- }
- 20% {
- transform: translateX(-100%) skewX(15deg);
- }
- 28% {
- transform: translateX(-100%) skewX(0deg);
- animation-timing-function: ease-out;
- }
- 45% {
- transform: translateX(-100%) skewX(-5deg) rotate(20deg) scaleY(1.1);
- animation-timing-function: ease-in-out;
- }
- 50% {
- transform: translateX(-100%) rotate(45deg) scaleY(1.1);
- animation-timing-function: ease-in;
- }
- 60% {
- transform: translateX(-100%) rotate(90deg);
- }
- 65% {
- transform: translateX(-100%) rotate(90deg) skewY(10deg);
- }
- 70% {
- transform: translateX(-100%) rotate(90deg) skewY(0deg);
- }
- to {
- transform: translateX(-100%) rotate(90deg);
- }
- }
- @-webkit-keyframes shift {
- from {
- -webkit-transform: translateX(-300%);
- }
- }
- @keyframes shift {
- from {
- transform: translateX(-300%);
- }
- }
- </style>
- </head>
- <body>
- <h1 class="logo">
- <!-- This is the box we are animating -->
- <span class="box-outer"><span class="box-inner"></span></span>
- <span class="logo-box">Box</span><span class="logo-model">model</span>
- </h1>
- </body>
- </html>
|