好玩的进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>
相关推荐
码艺-Alimjan13 小时前
横向滚动组件纯用 CSS,丝滑鼠标滚动不许js
javascript·css·计算机外设
砚凝霜16 小时前
软考网络工程师|案例分析:Eth‑Trunk 链路聚合、iStack 堆叠、CSS 集群核心考点总结
前端·css·网络
二级小助手16 小时前
二级Web前端选择题高频真题20道与考场避坑笔记
javascript·css3·html5·web前端·计算机二级·二级web·web真题
杀生丸学AI19 小时前
【三维重建】QuerySplat:在 3DGS 预测中解耦几何与外观表征
人工智能·3d·三维重建·扩散模型·高斯泼溅·空间智能·室内重建
杀生丸学AI2 天前
【世界模型】Lyra 2.0:可探索的生成式3D世界(NVIDIA)
人工智能·深度学习·3d·数据挖掘·transformer·世界模型·高斯泼溅
毕安格 - BimAngle2 天前
国家电网 GIM 格式模型一键输出 3D Tiles (for Cesium) 和 glTF/glb 更新时间:2026-08-18
3d·gis·cesium·gltf·glb·3d tiles·gim
breeze jiang2 天前
CSS 三栏布局怎么写:Flex、Grid 完整方案与 BFC 区别
前端·css
何时梦醒2 天前
CSS 三栏布局与 BFC 深度解析:Float、Flex、Grid 三种方案一网打尽
前端·css·面试
烬羽2 天前
CSS 三栏布局:`margin-left: -100%` 凭什么把侧栏「拽」回上一行?彻底搞懂负 margin
css·面试·前端框架
BreezeJiang2 天前
写了 display:flex,为什么三栏布局还没完成?
前端·css