Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> CSS

Tạo hiệu ứng chuyển động cho thuộc tính CSS width


Để thực hiện animation trên thuộc tính width với CSS, bạn có thể chạy đoạn mã sau:

Ví dụ

<!DOCTYPE html> <html>    <head>       <style>          div {             width: 300px;             height: 250px;             background-color: maroon;             color: white;             animation: myanim 3s;          }          @keyframes myanim {             30% {                width: 500px;             }          }       </style>    </head>    <body>       <h1>CSS width property</h1>       <div>          <h1>This is demo text!</h1>       </div>    </body> </html>