div+css实现立体进度条抖动加载动画效果代码

代码语言:html

所属分类:加载滚动

代码描述:div+css实现立体进度条抖动加载动画效果代码,鼠标悬浮可切换视角,鼠标按住不放可暂停。

代码标签: div css 立体 进度条 抖动 加载 动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

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

<head>
 
<meta charset="UTF-8">
 

 
 
<style>
@import url('https://fonts.googleapis.com/css2?family=Days+One&family=Gluten&display=swap');

:root {
        --bg: #3d373f;
        --sp: 0.45s;
        --dy: calc(var(--sp) / 8);
        --ttf: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

* {
        transform-style: preserve-3d;
        box-sizing: border-box;
}

body {
        margin: 0;
        padding: 0;
        width: 100vw;
        height: 100vh;
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--bg);
        flex-wrap: wrap;
}

body:before, body:after {
        content: "hover to change perspective";
        position: absolute;
        width: 100%;
        text-align: center;
        text-transform: uppercase;
        font-family: 'Gluten', Arial, Helvetica, serif;
        color: #796b79;
        text-shadow: 0px -1px 1px #c9b0c9cc, 0px -1px 0 #0008, 0px 2px 2px #0008;
        top: 5vh;
        left: 0;
        z-index: -1;
}

body:after {
        content: "click & hold to pause animation";
        top: 95vh;
}

.content {
        width: 80vmin;
        height: 80vmin;
        background: var(--bg);
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 2vmin;
        perspective-origin: 50% 50%;
        perspective: 100vmin;
        position: absolute;
        transition: all 0.33s ease 0s;
}

.cuboids {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: row-reverse;
        gap: 2vmin;
}

.cuboid {
        --height: 15;
        --width: 3;
        --depth: 6;
        --hue: 300;
        --sat: 8%;
        height: calc(var(--height)* 1vmin);
        width: calc(var(--width)* 1vmin);
        transform: translateZ(calc(-3vmin + 1px));
        animation: leaping var(--sp) var(--ttf) 0s infinite alternate;
}

@keyframes leaping {
        100% { transform: translateZ(3vmin); }
}

.cuboid .side {
        position: absolute;
        top: 50%;
        left: 50%;
        height: 100%;
        width: 100%;
        border-radius: 2px;
        background: hsl(var(--hue), var(--sat), 10%);
}

.cuboid .side:nth-of-type(1) {
        transform: translate3d(-50%, -50%, calc(var(--depth) * 0.5vmin));
        border-top: 1px solid hsl(var(--hue), var(--sat), 50%);
        animation: lights var(--sp) var(--ttf) 0s infinite alternate;
        background: linear-gradient(0deg, hsl(var(--hue), var(--sat), 25%), hsl(var(--hue), var(--sat), 55%));
        background-size: 100% 300%;
}

@keyframes lights {
        0% { background-position: 0 100%;       }
        100% { background-position: 0 0%;       }

}

.cuboid .side:nth-of-type(2) {
        transform: translate3d(-50%, -50%, calc(var(--depth) * -0.5vmin)) rotateY(180deg);
}
.cuboid .side:nth-of-type(3) {
        width: calc(var(--depth) * 1vmin);
        transform: translate(-50%, -50%) rotateY(90deg) translate3d(0, 0, calc(var(--width) * 0.5vmin));
}
.cuboid .side:nth-of-type(4) {
        width: calc(var(--depth) * 1vmin);
        transform: translate(-50%, -50%) rotateY(-90deg) translate3d(0, 0, calc(var(--width) * 0.5vmin));
}
.cuboid .side:nth-of-type(5) {
        height: calc(var(--depth) * 1vmin);
        transform: translate(-50%, -50%) rotateX(90deg) translate3d(0, 0, calc(var(--height) * 0.5vmin));
}
.cuboid .side:nth-of-type(6) {
        height: calc(var(--depth) * 1vmin);
        transform: translate(-50%, -50%) rotateX(-90deg) translat.........完整代码请登录后点击上方下载按钮下载查看

网友评论0