思路:使用animation设置动画,使用rect.style.animationDuration设置动画持续时间(注意单位是s)。 <style type="text/css"> #rect { width: 120px; height: 100px; background-color: black; animation:rect 10s } @keyframes rect { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } </style> <body> <...