css实现直线拉伸

发布时间 2023-06-12 07:38:03作者: 朱龙旭看世界
<!DOCTYPE html>  
<html lang="en">  
<head>  
  <meta charset="UTF-8">  
  <title>直线拉伸示例</title>  
  <style>  
    .line {  
      height: 2px;  
      background-color: black;  
      animation: stretch-line 1s ease-in-out forwards;  
    }  
    @keyframes stretch-line {  
      0% {  
        width: 0;  
      }  
      100% {  
        width: 200px; /* 指定直线长度 */  
      }  
    }  
  </style>  
</head>  
<body>  
  <div class="line"></div>  
</body>  
</html>