首頁  >  文章  >  web前端  >  使用CSS3過渡transition效果實例介紹

使用CSS3過渡transition效果實例介紹

高洛峰
高洛峰原創
2017-03-13 17:47:001604瀏覽

這篇文章主要為大家詳細介紹了CSS3過渡transition效果實例,具有一定的參考價值,有興趣的小夥伴們可以參考一下

本文實例為大家分享了CSS3過渡transition效果,供大家參考,具體內容如下

效果圖:

使用CSS3過渡transition效果實例介紹

#實作程式碼:

#transition.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Transition</title>
    <style>
        #block {     
            width: 400px;     
            height: 300px;     
            background-color: #69C;     
            margin: 0 auto;     

            transition: background-color 1s, width 0.5s ease-out;     
            -webkit-transition: background-color 1s, width 0.5s ease-out;     
        }     
        #block:hover {     
            background-color: red;     
            width: 600px;     
        }     
    </style>
</head>
<body>
    <p id="block">

    </p>
</body>
</html>


#transitionDemo.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>TransitionDemo</title>
    <style>
        #wrapper {     
            width: 1024px;     
            margin: 0 auto;     
        }     
        .progress-bar-bg {     
            width: 960px;     
            /*background-color: aliceblue;*/     
            background-color: lightyellow;     
        }     
        .progress-bar {     
            height: 40px;     
            width: 40px;     
            background-color: #69C;     

            border: 1px solid lightyellow;     
            border-radius: 5px;     
        }     
        .progress-bar:hover {     
            width: 960px;     
        }     

        #bar1 {     
            -webkit-transition: width 5s linear;     
            /*-webkit-transition: width 5s steps(6, end);*/     
            /*-webkit-transition: width 5s step-start;*/     
        }     
        #bar2 {     
            -webkit-transition: width 5s ease;     
        }     
        #bar3 {     
            -webkit-transition: width 5s ease-in;     
        }     
        #bar4 {     
            -webkit-transition: width 5s ease-out;     
        }     
        #bar5 {     
            -webkit-transition: width 5s ease-in-out;     
        }     
    </style>
</head>
<body>
<p id="wrapper">
    <p>linear</p>
    <p class="progress-bar-bg">
        <p class="progress-bar" id="bar1"></p>
    </p>

    <p>ease</p>
    <p class="progress-bar" id="bar2"></p>

    <p>ease-in</p>
    <p class="progress-bar" id="bar3"></p>

    <p>ease-out</p>
    <p class="progress-bar" id="bar4"></p>

    <p>ease-in-out</p>
    <p class="progress-bar" id="bar5"></p>
</p>
</body>
</html>


結果分析:滑鼠移動上去後,會發生過渡動畫。

以上就是本文的全部內容,希望對大家的學習有所幫助。

以上是使用CSS3過渡transition效果實例介紹的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn