ccs3动画-div向上移动的动画

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .contain {
            padding: 100px 20px;
            display: flex;
        }

        .demo {
            width: 200px;
            height: 140px;
            background: red;
            text-align: center;
            line-height: 140px;
            margin-left: 20px;
            /* 动画整个过程持续0.4s,移入和移出持续0.4s; 谁动画,动画状态写谁  */
            transition: all 0.4s;
        }

        /* 鼠标移入的时候 div向上移动8px */
        .demo:hover {
            background: pink;
            margin-top: -8px;
        }
    </style>
</head>
<body>
    <div class="contain">
        <div class="demo">
            我是文字
        </div>
        <div class="demo">
            我是文字
        </div>
        <div class="demo">
            我是文字
        </div>
        <div class="demo">
            我是文字
        </div>
    </div>
</body>

相关文章

HTML5和CSS3实现3D展示商品信息的代码
利用HTML5中的Canvas绘制笑脸的代码
Html5剪切板功能的实现
如何通过HTML5触摸事件实现移动端简易进度条
Html5移动端获奖无缝滚动动画实现
关于HTML5和CSS3实现机器猫的代码