CSS动画
HTML代码
1 2 3 4 5 6 | <div class="wrapper"> <div class="bird"> <div class="beak"></div> <div class="wing"></div> </div> </div> |
CSS代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | /* Pure CSS3 animation Bird */ /* Author : Ranjith ( ranjith.co.in ) */ body{ background:#4c0854; outline:none; } .wrapper { height: 250px; left: 50%; margin: -10% 0 0 -10%; position: absolute; top: 50%; width: 250px; } .bird { background:#8d2299; width:200px; height:275px; position:relative; border-radius:40% 40% 40% 0; } .bird:before{ position:absolute;top:0; height:25px; width:25px; background:#4c0854; z-index:2; content:""; top:50px; left:120px; border-radius:50%; } .bird:after{ background: none repeat scroll 0 0 #8D2299; border-radius: 20px 0; content: ""; height: 50px; left: 0; position: absolute; top: 255px; width: 20px; z-index: 2; } .wing{ background: none repeat scroll 0 0 #D0007F; border-radius: 0 55% 0 60%; content: ""; height: 150px; left: -72px; position: absolute; top: 78px; transform: rotate(-156deg); -webkit-transform:rotate(-156deg); width: 250px; } div.beak { background-color: #FCAC39; border-radius: 0 25px; height: 55px; position: absolute; top: 35px; width: 75px; z-index: -1; right:-30px; } div.beak:after{ background-color: #E99138; border-radius:25px 0; content: ""; display: block; height: 25px; margin-right: -17px; position: absolute; right: 32%; top: 100%; width: 50px;outline:none; animation: 0.5s linear 0s normal none infinite open; animation-play-state: paused; -webkit-animation: open .5s linear infinite; -webkit-animation-play-state: paused; -moz-animation: open .5s linear infinite; -moz-animation-play-state: paused; -ms-animation: open .5s linear infinite; -ms-animation-play-state: paused; } .bird:hover .beak:after { -webkit-animation-play-state: running; -moz-animation-play-state: running; -ms-animation-play-state: running; -o-animation-play-state: running; animation-play-state: running; -webkit-transform:rotate(45deg); -o-transform:rotate(45deg); } @keyframes open { 50% { transform:rotate(45deg); -ms-transform:rotate(45deg); -webkit-transform:rotate(45deg); } } @-moz-keyframes open { 50% { transform:rotate(45deg); -ms-transform:rotate(45deg); -webkit-transform:rotate(45deg); } } @-webkit-keyframes open { 50% { transform:rotate(45deg); -ms-transform:rotate(45deg); -webkit-transform:rotate(45deg); } } |