首页 > 其他 > 详细

#transform #transition 通过类名实现文字动画过渡

时间:2020-05-05 09:57:29      阅读:49      评论:0      收藏:0      [点我收藏+]

技术分享图片

代码

<!DOCTYPE html>
<html>

<head>
    <style>
        div {
            display: flex;
            justify-content: center;
            align-items: center;
            position: absolute;
            top: 200px;
            width: 300px;
            height: 300px;


            background: red;
            transition: width .5s,transform .5s,top .5s,height .5s;
        }

        .customStyle {

            top: 200px;
            width: 300px;
            height: 100px;
            transform: translateX(500px);
        }
    </style>
</head>

<body>

    <div id="test">
        <h1>我是中国人</h1>
    </div>

    <button onClick="trigger()">点击</button>
    <button onClick="triggeroff()">移出</button>
    <script>
        function trigger() {

            document.getElementById("test").classList.add("customStyle")
        }
        function triggeroff() {

            document.getElementById("test").classList.remove("customStyle")
        }
    </script>
</body>

</html>

#transform #transition 通过类名实现文字动画过渡

原文:https://www.cnblogs.com/jaycethanks/p/12829077.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!