通过CSS3使图片从左上角移动到右下角

去网上着了好久都没找到,后来想到了cacl计算属性才解决

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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
    html,body{
        height:100%;
    }
    .ani-box {
        width: 100%;
        height: 100%;
        position: relative;
    }

    .ani {
        width: 100px;
        height: 100px;
        background: #000;
        animation: a 2s linear;
        position: absolute;
        top: 0;
        left: 0;
    }

    @keyframes a {
        0% {
            top:0;
        }
        100% {
            top:calc(100% - 100px);
        }
    }
</style>

<body>
<div class="ani-box">
<div class="ani"></div>
</div>
</body>

</html>

完~

猜你喜欢

转载自blog.csdn.net/Mr_YanYan/article/details/80055897