惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
爱范儿
爱范儿
GbyAI
GbyAI
博客园 - 叶小钗
Last Week in AI
Last Week in AI
Jina AI
Jina AI
Microsoft Security Blog
Microsoft Security Blog
云风的 BLOG
云风的 BLOG
C
Check Point Blog
H
Help Net Security
P
Proofpoint News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
大猫的无限游戏
大猫的无限游戏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
B
Blog RSS Feed
Y
Y Combinator Blog
U
Unit 42
T
Tailwind CSS Blog
MyScale Blog
MyScale Blog
N
Netflix TechBlog - Medium
S
SegmentFault 最新的问题
J
Java Code Geeks
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

博客园 - smile轉角

【js】ES5,ES6继承是如何实现的 【js】setTimeout、Promise、Async/Await 的区别 【面试题】思维逻辑方面 【js】js内置对象Error(错误机制) 【TS】学习笔记 【js】CommonJS、AMD、CMD三种规范 【其他】查看Animate.css官网动画没有效果 【vue3】父子组件通信之 vue3 defineProps,defineEmits ,defineExpose 【js】JS严格模式有什么特点 【css】使用弹性盒子布局时,省略号问题 【vue】 Failed to load resource: the server responded with a status of 404 (Not Found) 【第三方】富文本调研 【js】元素是否在可视区范围内 【js】json的相关操作 【vue3】资料 【css】展示背景图片的底部部分 【html】 svg 【js】forEach,for...in,for...of 区别 【js】map,reduce,filter的区别
【html5】html5中input 标签 type值为range时,修改其默认css
smile轉角 · 2022-08-12 · via 博客园 - smile轉角

demo

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        input[type="range"] {
            -webkit-appearance: none; /* 去除默认样式 */
            background: -webkit-linear-gradient(red, red) no-repeat, #dedede;
            background-size: 0 100%;
            width: 200px;
            height: 2px;
            border-radius: 15px;
            
        }
 
        /* 去除获取焦点时的边框 */
        input[type="range"]:focus {
            outline: none;
        }
 
        /* chrome自定义滑动轨道 */
        input[type="range"]::-webkit-slider-runnable-track {
            height: 2px;
            border-radius: 15px;
        }
 
        /* chrome自定义滑块 */
        input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            position:relative;
            top:-4px;
            width: 12px;
            height: 12px;
            border:1px solid red;
            background: #fff;
            border-radius: 50%;

        }
 
        /* firefox自定义滑动轨道 */
        input[type="range"]::-moz-range-track {
            background: #dedede;
            height: 2px;
        }
 
        /* firefox自定义滑块 */
        input[type="range"]::-moz-range-thumb {
            position:relative;
            top:-4px;
            width: 12px;
            height: 12px;
            border:1px solid red;
            background: #fff;
            border-radius: 50%;
        }
 
        /* firefox根据滑块位置填充进度条 */
        input[type="range"]::-moz-range-progress {
            height: 2px;
            background: red;
        }
 
        /* IE自定义滑动轨道 */
        input[type="range"]::-ms-track {
            height: 2px;
            border-color: transparent; /* 去掉原有边框 */
            color: transparent; /* 去掉轨道内的竖线 */
            border-radius: 15px;
            background: #dedede;
        }
 
 
        /* IE自定义滑块 */
        input[type="range"]::-ms-thumb {
            position:relative;
            top:-4px;
            width: 12px;
            height: 12px;
            border:1px solid red;
            background: #fff;
            border-radius: 50%;
        }
 
        input[type=range]::-ms-fill-lower { /*进度条已填充的部分*/
            background: red;
        }
 
        input[type=range]::-ms-fill-upper { /*进度条未填充的部分*/
            background: #dedede;
        }
    </style>
</head>
 
<body>
    <div>
        <input id="range" type="range" max="100" min="0" value="0">
    </div>
</body>
<script>
    // 谷歌通过js修改填充进度条颜色
    var range = document.getElementById("range");
    range.onmousemove = function () {
        range.style.backgroundSize = range.value + '% 100%';
    }
</script>
 
</html>

效果图