使用 CSS Animation 为 transform 属性添加动画

cssweb developmentfront end technology更新于 2026/2/3 4:28:17

要使用 CSS 为 transform 属性添加动画,您可以尝试运行以下代码 −

示例

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            margin: auto;
            border: 2px solid blue;
            width: 300px;
            height: 400px;
            background-color: orange;
            animation: myanim 3s;
         }
         @keyframes myanim {
            30% {
               transform: rotate(120deg);
            }
         }
      </style>
   </head>
   <body>
      <h1></h1>
      <div>
         <h1>Demo</h1>
      </div>
   </body>
</html>

相关文章


有用资源