设置过渡效果的 CSS 属性名称

cssweb developmentfront end technology更新于 2024/7/18 14:04:17

要设置过渡效果的 CSS 属性名称,请使用 CSS transition-property。

在下面的示例中,我们将属性设置为宽度,并设置了持续时间:

示例

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

相关文章


有用资源