CSS3中關於transition屬性的執行個體分析

來源:互聯網
上載者:User

一、說明

1.1 定義和用法

transition 屬性是一個簡寫屬性,用於設定四個過渡屬性:

transition-property:規定設定過渡效果的CSS屬性的名稱。

transition-duration:規定完成過渡效果需要多少秒或毫秒。

transition-timing-function:規定速度效果的速度曲線。

transition-delay:定義過渡效果何時開始。

1.2 文法

transition: property duration timing-function delay;

1.3 transition-timing-function

1.3.1 文法
transition-timing-function: linear|ease|ease-in|ease-out|ease-in-out|cubic- bezier(n,n,n,n);
1.3.2 說明
linear:規定以相同速度開始至結束的過渡效果(等於cubic-bezier(0,0,1,1))。ease:規定慢速開始,然後變快,然後慢速結束的過渡效果(cubic-bezier(0.25,0.1,0.25,1))。ease-in:規定以慢速開始的過渡效果(等於cubic-bezier(0.42,0,1,1))。ease-out:規定以慢速結束的過渡效果(等於cubic-bezier(0,0,0.58,1))。ease-in-out:規定以慢速開始和結束的過渡效果(等於cubic-bezier(0.42,0,0.58,1))。cubic-bezier(n,n,n,n):在cubic-bezier函數中定義自己的值。可能的值是0至1之間的數值。

二、樣本

<style>    .transition-example{        width: 500px;        height: 370px;        background: #ccc;        padding: 10px 0;    }    .transition-example:hover>p{        margin-left: 90%;        transform: rotate(360deg);        border-radius: 5px;    }    .transition-example>p{        width: 50px;        height: 50px;        text-align: center;        margin: 10px 0;        background-color: blue;        color: #fff;    }    .linear{        transition: all 5s linear;    }    .ease{        transition: all 5s ease;    }    .ease-in{        transition: all 5s ease-in;    }    .ease-out{        transition: all 5s ease-out;    }    .ease-in-out{        transition: all 5s ease-in-out;    }    .cubic-bezier{        transition: all 5s cubic-bezier(0.42,0,0.58,1);    }    </style><p class="transition-example">    <p class="linear">linear</p>    <p class="ease">ease</p>    <p class="ease-in">ease-in</p>    <p class="ease-out">ease-out</p>    <p class="ease-in-out">ease-in-out</p>    <p class="cubic-bezier">cubic-bezier</p></p>
lineareaseease-inease-outease-in-outcubic-bezier
相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.