css动画

xiaoxiao2025-08-13  22

代码

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style> *{margin: 0;padding: 0;} .box{width: 640px;height: 310px;margin:auto;position: relative;margin-top: 5%;} .a1{position: relative;} .b1{position: relative;} .a{width: 310px;height: 310px;background: red;opacity: .5; border-radius: 50%;position: absolute;left: 0;animation:mymove 2s infinite linear alternate;cursor: pointer;} .b{width: 310px;height: 310px;background: blue;opacity: .5; border-radius: 50%;position: absolute;right: 0;animation:mymove1 2s infinite linear alternate;cursor: pointer;} .a:hover{opacity: 1;} .b:hover{opacity: 1;} .left{float: left;} .right{float: right;} @keyframes mymove { from {left:0px;} to {left:50px;} } @-webkit-keyframes mymove { from {left:0px;} to {left:50px;} } @keyframes mymove1 { from {right:0px;} to {right:50px;} } @-webkit-keyframes mymove1 /*Safari and Chrome*/ { from {right:0px;} to {right:50px;} } </style> </head> <body> <div class="box"> <div class="left a1"> <div class="a"></div> </div> <div class="right b1"> <div class="b"></div> </div> <div class="clear"></div> </div> </body> </html>
转载请注明原文地址: https://www.6miu.com/read-5034770.html

最新回复(0)