CSS top 属性动画

cssweb developmentfront end technology更新于 2026/2/2 22:36:17

要使用 CSS 在 top  属性上实现动画,您可以尝试运行以下代码 −

示例

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            position: absolute;
            width: 300px;
            height: 200px;
            background-color: orange;
            color: white;
            top: 0;
            animation: myanim 3s infinite;
         }
         @keyframes myanim {
            30% {
               top: 300px;
            }
         }
      </style>
   </head>
   <body>
      <h1>CSS top property</h1>
      <div>
         <h1>This is demo text!</h1>
      </div>
   </body>
</html>

相关文章


有用资源