用HTML、CSS写一个酷炫的动态特效

导读:本篇文章讲解 用HTML、CSS写一个酷炫的动态特效,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

在油管看到了一个酷炫的动态特效,我也试着用HTML和CSS做了一下

HTML部分:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
    <div class="container">
        <div class="box">
            <div class="cube">
            </div>
        </div>
    </div>
</body>
</html>

CSS部分:

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #000;
    overflow: hidden;
}

.container {
    position: relative;
    width: 100%;
    transform: rotate(-35deg);
}

.container .box {
    position: relative;
    left: -200px;
    display: flex;
    justify-content: center;
    width: calc(100% +400px);
    -webkit-box-reflect: below 1px linear-gradient(transparent, #0004);
    animation: animateSurface 1.5s ease-in-out infinite;
}

@keyframes animateSurface {
    0% {
        transform: translateX(0px);
    }

    100% {
        transform: translateX(-200px);
    }
}

.container .box .cube {
    position: relative;
    width: 200px;
    height: 200px;
    background: #03e9f4;
    box-shadow: 0 0 5px rgba(3, 233, 244, 1),
        0 0 25px rgba(3, 233, 244, 1),
        0 0 50px rgba(3, 233, 244, 1),
        0 0 100px rgba(3, 233, 244, 1),
        0 0 200px rgba(3, 233, 244, 0.5),
        0 0 300px rgba(3, 233, 244, 0.5);
    transform-origin: bottom right;
    animation: animate 1.5s ease-in-out infinite;
}

@keyframes animate {
    0% {
        transform: rotate(0deg);
    }

    60% {
        transform: rotate(90deg);
    }

    65% {
        transform: rotate(85deg);
    }

    70% {
        transform: rotate(90deg);
    }

    75% {
        transform: rotate(87.5deg);
    }

    80%,
    100% {
        transform: rotate(90edg);
    }

}

在这里插入图片描述

结果是一个动态沿着斜面滚动的方块,斜面角度,或者滚动方向可以自行设置,静态的页面是固定的,照搬就行了

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/79726.html

(0)
小半的头像小半

相关推荐

极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!