css动画效果放大缩小、颤抖、旋转等
放大缩小
演示地址:http://wk517.com/old/default.html#css3
.anim1 { animation: myfirst 2s infinite; } @keyframes myfirst { 0% { transform: translate(0px, 0px); -webkit-transition: scale(1); -moz-transition: scale(1); -ms-transition: scale(1); -o-transition: scale(1); transform: scale(1) } 50% { transform: translate(0px, -15px); -webkit-transition: scale(1.2); -moz-transition: scale(1.2); -ms-transition: scale(1.2); -o-transition: scale(1.2); transform: scale(1.2) } 100% { transform: translate(0px, 0px); -webkit-transition: scale(1); -moz-transition: scale(1); -ms-transition: scale(1); -o-transition: scale(1); transform: scale(1) } }
旋转、大转盘效果
鼠标经过旋转
.xuanzhuan { text-align: center; transition:all 0.5s linear; -webkit-transition:all 0.5s linear; -moz-transition:all 0.5s linear; -ms-transition:all 0.5s linear; -o-transition:all 0.5s linear; } .xuanzhuan:hover { transform:rotate(180deg); -webkit-transform:rotate(180deg); -moz-transform:rotate(180deg); -ms-transform:rotate(180deg); -o-transform:rotate(180deg); }
html
<div class="windmill2"> <span class="djcj"></span> <span class="axis"> <!--<img src="images/zhuanpans.png">--> </span> </div>
css
@-webkit-keyframes rotate { from { -webkit-transform:rotate(0) } to { -webkit-transform:rotate(360deg) } } @-moz-keyframes rotate { from { -moz-transform:rotate(0) } to { -moz-transform:rotate(359deg) } } @-o-keyframes rotate { from { -o-transform:rotate(0) } to { -o-transform:rotate(359deg) } } @keyframes rotate { from { transform:rotate(0) } to { transform:rotate(359deg) } } @-webkit-keyframes rotate2 { from { -webkit-transform:rotate(0) } to { -webkit-transform:rotate(360deg) } } @-moz-keyframes rotate2 { from { -moz-transform:rotate(0) } to { -moz-transform:rotate(359deg) } } @-o-keyframes rotate2 { from { -o-transform:rotate(0) } to { -o-transform:rotate(359deg) } } @keyframes rotate2 { from { transform:rotate(0) } to { transform:rotate(359deg) } } .windmill2 { display:block; position:relative; width:200px; height:200px; overflow:hidden } .windmill2 .axis { position:absolute; top:0; left:0; width:200px; height:200px; overflow:hidden; z-index:1; -webkit-transition-property:-webkit-transform; -webkit-transition-duration:3s; -moz-transition-property:-moz-transform; -moz-transition-duration:3s; -webkit-animation:rotate 14s linear infinite; -moz-animation:rotate 14s linear infinite; -o-animation:rotate 14s linear infinite; animation:rotate 14s linear infinite; background:#09f; border-radius:50% 0 50% 0 } .windmill2 .axis img { width:200px; height:200px } .djcj { position:absolute; width:40px; height:40px; left:50%; top:50%; margin:-20px 0 0 -20px; z-index:2; cursor:pointer; background:#f60 } .djcj img { width:40px; height:40px }
css跳动
<div class"tiaodong"></div> .tiaodong { animation: myfirst 2s infinite; } @keyframes myfirst { 0% { transform: translate(0px, 0px); } 50% { transform: translate(0px, -10px); } 100% { transform: translate(0px, 0px); } }
摇摆 颤抖
.redbag { position:relative; -webkit-animation: alarm-2 4ms infinite; animation: alarm-2 4ms infinite; } @keyframes tick-tock { to { transform: rotate(360deg); } } @-webkit-keyframes tick-tock { to { -webkit-transform: rotate(360deg) translate3d(0, 0, 0); } } @-webkit-keyframes alarm { from { -webkit-transform-origin: bottom right; -webkit-transform: rotate(15deg); } to { -webkit-transform-origin: bottom left; -webkit-transform: rotate(-15deg); } } @keyframes alarm { from { transform-origin: bottom right; transform: rotate(15deg); } to { transform-origin: bottom left; transform: rotate(-15deg); } } @-webkit-keyframes alarm-2 { from { -webkit-transform: rotate(1deg); } to { -webkit-transform: rotate(-1deg); } } @keyframes alarm-2 { from { transform: rotate(1deg); } to { transform: rotate(-1deg); } }
摇摆
.huangdong { -webkit-animation:swinging 2s ease-in-out 0s infinite; -moz-animation:swinging 2s ease-in-out 0s infinite; animation:swinging 2s ease-in-out 0s infinite; -webkit-transform-origin: 50% 100%; -moz-transform-origin: 50% 100%; transform-origin: 50% 100%; } @-webkit-keyframes swinging { 0% { -webkit-transform: rotate(10deg); } 50% { -webkit-transform: rotate(-10deg); } 100% { -webkit-transform: rotate(10deg); } }
闪光
@-webkit-keyframes twinkling { /*透明度由0到1*/ 0% { opacity: 0.1; /*透明度为0*/ } 100% { opacity: 1; /*透明度为1*/ } } @keyframes twinkling { /*透明度由0到1*/ 0% { opacity: 0.1; /*透明度为0*/ } 100% { opacity: 1; /*透明度为1*/ } } .element { -webkit-animation: twinkling 1s infinite ease-in-out; }