如何使用 CSS 过渡效果?

cssweb developmentfront end technology更新于 2024/7/18 10:20:17

使用 transition  属性来使用 CSS 过渡效果。

您可以尝试运行以下代码在 CSS 中实现过渡效果:

示例

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            width: 150px;
            height: 150px;
            background: blue;
            transition: width 4s;
         }
         div:hover {
            width: 200px;
         }
      </style>
   </head>
   <body>
      <h1>Heading One</h1>
      <p>Hover over the below box to change its width.</p>
      <div></div>
   </body>
</html>

相关文章


有用资源