設定過渡效果的 CSS 屬性的名稱


要設定過渡效果的 CSS 屬性的名稱,請使用 CSS transition-property。

在以下示例中,我們已將屬性設定為 width,並設定了 duration

示例

即時演示

<!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>

更新於:2020 年 6 月 24 日

78 次瀏覽

開啟你的職業生涯

透過完成課程獲得認證

開始學習
廣告
© . All rights reserved.