049——VUE中使用animation與transform實現vue的動畫效果


<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>使用animation與transform實現vue的動畫效果</title>
    <script src="vue.js"></script>
</head>
<body>

<div id="hdcms">
    <button @click="type=!type">顯示/隱藏</button>
    <transition name="lt">
        <h1 v-if="type">http://www.baidu.com百度一下就知道</h1>
    </transition>
</div>

<script>
    new Vue({
        el: "#hdcms",
        data: {
            type: false
        }
    });
</script>
<!--
    animation:活潑;
    transition:過渡
    transform:改變
    translate:轉化
-->
<style type="text/css">
    .lt-enter-active{
        animation: show-in 1s;
        transition: all 1s;
    }
    .lt-leave-active{
        animation: show-out 1s;
        transition: all 1s;
    }

    .lt-enter,.lt-leave-to{
        opacity: 0;
    }
    @keyframes show-in {
        0%{
            transform: translate(200px,0);
        }
        100%{
            transform: translate(0,0);
        }
    }
    @keyframes show-out {
        0%{
            transform: translate(0,0);
        }
        100%{
            transform: translate(200px,0);
        }
    }
</style>
</body>

</html>

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM