首页 > Web开发 > 详细

css之transition上下动画效果

时间:2020-09-08 22:09:46      阅读:101      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>css之transition动画效果</title>
    <style>
        body,html{
            position: relative;
        }
        #root{
            position: relative;
            top: 200px;
            left: calc(50% - 150px);
            width: 300px;
            height: 300px;
            background-color: yellow ;
            overflow: hidden;
        }
        #root:hover #box{
            top: 0;
        }
        #box{
            width: 300px;
            height: 300px;
            background-color: skyblue;
            position: absolute;
            top: -100%;
            transition: all ease-in 2s;
        }
        #box button {
            position: absolute;
            bottom: 0;
            right: 0;
        }
        #box:active{
            background-color: red;
        }
    </style>
</head>
<body>
    <div id="root">
        <div id="box">
            <button onclick="toBuy()">购买</button>
        </div>
    </div>
</body>
</html>
<script>
    function toBuy(){
        alert(购买成功)
    }
</script>

 

css之transition上下动画效果

原文:https://www.cnblogs.com/-roc/p/13634838.html

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