设置 CSS 过渡效果的延迟

cssweb developmentfront end technology更新于 2024/7/18 13:00:17

使用 transition-delay属性,通过 CSS 设置过渡效果的延迟。您可以尝试运行以下代码,设置 1 秒的过渡延迟:

示例

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            width: 150px;
            height: 150px;
            background: blue;
            transition: width 3s;
            transition-delay: 2s;
         }
         div:hover {
            width: 350px;
         }
      </style>
   </head>
   <body>
      <h1>Heading One</h1>
      <p>Hover over the below box to change its width. It begins with a delay of 2 seconds.</p>
      <div></div>
   </body>
</html>

相关文章


有用资源