动画充电
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> #div1 { height: 200px; position: relative; } /* 电池本身 */ .dian { width: 50px; height: 100px; border-radius: 5px; border: 1px solid red; margin: 10% auto; background-color: #fff; overflow: hidden; } /* 电池头 */ .dian::before { content: ""; position: absolute; height: 5px; width: 10px; margin-top: -7px; margin-left: 19px; border: 1px solid red; } .diao1 { background: linear-gradient( red, yellow, green, blueviolet); margin-top: 98px; height: 100px; animation: aaa 2s infinite linear; } /* 充电的格子 */ .diao2 { width: 50px; height: 140px; margin-top: -20px; background-color: aqua; } /* 滚动园 */ .diao22 { transform: rotate(42deg); width: 100px; height: 100px; border-radius: 45%; margin-left: -28px; margin-top: -10px; text-shadow: 0 5px 5px rgb(63, 63, 77); background-color: #fff; animation: ccc 1s infinite linear; } /* 包着 格子和园 */ .dian11 { animation: cc1 10s infinite linear; } /* 园的旋转 */ @keyframes ccc { from { transform: rotate(180deg); } to { transform: rotate(360deg); } } /* 格子和园上升 */ @keyframes cc1 { from { margin-top: -10px; } to { margin-top: -104px; } } /* 格子上升 */ @keyframes aaa { from { margin-top: 98px; } to { margin-top: 0; } } </style> </head> <body> <!-- <div id="div1"> --> <div class="dian"> <div class="diao1"></div> </div> <!-- </div> --> <div id="div1"> <div class="dian"> <div class="dian11"> <div class="diao22"></div> <div class="diao2"></div> </div> </div> </div> </body> </html>