好玩的进3D度条

html 复制代码
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>好玩的3D进度条</title>
    <style>
        body {
            color: black;
            background: #3a6073;
        }
        .input-container {
            position: absolute;
            transform: translate(222%, 333%);
        }
        .input-container input {
            outline: none;
            background: none;
            font-size: 20px;
            color: #fff;
            border-radius: 10px;
            width: 100px;
        }
        img {
            width: 190px;
            position: absolute;
            top: -170px;
            left: -40px;
            transform: rotate(90deg);/
        }
        .progress-container {
            width: 400px;
            height: 270px;
            margin: 100px;
            perspective: 1000px;
            transform-origin: 50% 50%;
            transform-style: preserve-3d;
        }
        .progress-box div {
            text-align: center;
            line-height: 100px;
            position: absolute;
            width: 100%;
            height: 100%;
            background-color: rgba(16, 109, 52, 0.34)
        }
        .progress-box {
            width: 400px;
            height: 100px;
            position: relative;
            transform-style: preserve-3d;
            transition: 0.6s;
            transform-origin: 100% 50%;
            transform: rotateZ(-90deg);
        }
        .back-face {
            box-shadow: 0 -16px 80px rgba(0, 0, 0, 0.463),
                0 1px 1px rgba(19, 11, 11, 0.3),
                0 1px 1px rgba(8, 1, 1, 0.829);
            transform-origin: 50% 50%;
            transform: translateZ(-100px);
        }
        .front-face {
            transform-origin: 50% 1000%;
            transform: translateZ(0px);
        }
        .progress-box div.left-side {
            width: 100px;
            height: 100px;
            transform-origin: 0% 100%;
            transform: rotateY(90deg);
        }
        .progress-box div.right-side {
            width: 100px;
            height: 100px;
            right: 0;
            top: 0;
            transform-origin: 100% 0%;
            transform: rotateY(-90deg);
        }
        .top-side {
            width: 100px;
            height: 400px;
            transform-origin: 50% 0%;
            transform: rotateX(-90deg);
        }
        .bottom-side {
            width: 100px;
            height: 400px;
            transform-origin: 50% 100%;
            transform: rotateX(90deg);
        }
        .fill::before {
            width: 300px;
            height: 100px;
            background-color: rgba(255, 7, 7, 0.402);
            content: '';
            display: block;
            position: absolute;
            margin: 0;
            box-sizing: border-box;
            transition: all 0.5s ease-out;
        }
        .progress-container .progress-box .progress-tip {
            width: 60px;
            height: 50px;
            background-color: steelblue;
            transform: translateZ(-10px) translateY(110px);
            color: rgb(255, 255, 255);
            line-height: 50px;
            position: absolute;
            left: 270px;
            transition: all 0.5s ease-out;
        }
        .progress-container .progress-box .progress-tip::before {
            content: '';
            border-color: steelblue;
            position: absolute;
            left: 20px;
            top: -17px;
            width: 0;
            height: 0;
            border-style: solid;
            border-width: 10px;
            border-top-color: transparent;
            border-left-color: transparent;
            border-right-color: transparent;
        }
        .fill::before {
            background-color: #b76565;
            content: pointer;
        }
    </style>
</head>
<body>
    <div class="progress-container">
        <div class="progress-box">
            <div class="back-face fill"></div>
            <div class="front-face fill"></div>
            <div class="left-side"></div>
            <div class="right-side"></div>
            <div class="top-side fill"></div>
            <div class="bottom-side fill"></div>
            <div class="progress-tip">
                <span>80</span>
                <img src="抠的图.png" alt="">
            </div>
        </div>
    </div>
    <div class="input-container">
        <input type="text" class="per-value">
        <button class="confirm">确定</button>
        <button class="pause">暂停</button>
    </div>
    <script>
        let btn = document.querySelector('.confirm');
        let input = document.querySelector('.per-value');
        let tip = document.querySelector('.progress-tip');
        let tipValue = tip.children[0];
        let intervalId; // 用于存储setInterval的ID
        btn.onclick = function () {
            document.styleSheets[0].addRule('.fill::before', 'width:' + input.value * 4 + 'px');
            tip.style.left = input.value * 4 - 30 + 'px';
            tipValue.innerHTML = input.value;
        }
        function autoInput() {
            let values = [0, 20, 30, 40, 50, 60, 70, 80, 90, 100];
            let index = 0;
            intervalId = setInterval(() => {
                input.value = values[index];
                btn.onclick();
                index = (index + 1) % values.length;
            }, 500);
        }
        autoInput();
        document.querySelector('.pause').onclick = function () {
            if (intervalId) {
                clearInterval(intervalId);
                intervalId = null;
                this.innerText = "开始";
            } else {
                autoInput();
                this.innerText = "暂停";
            }
        }
    </script>
</body>
</html>
相关推荐
唯之为之3 小时前
巧用mask属性创建一个纯CSS图标库
css·svg
寻找沙漠的人5 小时前
前端知识补充—CSS
前端·css
mirrornan8 小时前
3D和AR技术在电商行业的应用有哪些?
3d·ar·3d建模·3d模型·三维建模
NoneCoder8 小时前
CSS系列(29)-- Scroll Snap详解
前端·css
无言非影8 小时前
vtie项目中使用到了TailwindCSS,如何打包成一个单独的CSS文件(优化、压缩)
前端·css
羊小猪~~9 小时前
前端入门之VUE--ajax、vuex、router,最后的前端总结
前端·javascript·css·vue.js·vscode·ajax·html5
工业3D_大熊10 小时前
3D开发工具HOOPS助力造船业加速设计与数字化转型
3d
zaf赵10 小时前
3D 高斯溅射 (Gaussian Splatting)技术,一种实现超写实、高效渲染的突破性技术
3d
前端Hardy14 小时前
HTML&CSS:酷炫的3D开关控件
前端·javascript·css·3d·html
devotemyself14 小时前
vue的ElMessage的css样式不生效
前端·css·vue.js