Notes
HTML
CSS
JS
Tools
Code Snippets
HTML Entity
About
Contact Us
Simple HTML/CSS/JS Range Slider with Progress
HTML
CSS
JS
Output
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"> <!-- bootstrap 5 CDN and css --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" integrity="sha512-Fo3rlrZj/k7ujTnHg4CGR2D7kSs0v4LLanw2qksYuRlEzO+tcaEPQogQ0KaoGN26/zrn20ImR1DfuLWnOo7aBA==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> <!-- google font and font awesome CDN --> <link href="https://fonts.googleapis.com/css2?family=Manrope:wght@200;300;400;500;600;700;800&family=Roboto&display=swap" rel="stylesheet"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" integrity="sha512-Fo3rlrZj/k7ujTnHg4CGR2D7kSs0v4LLanw2qksYuRlEzO+tcaEPQogQ0KaoGN26/zrn20ImR1DfuLWnOo7aBA==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <title>Simple HTML/CSS/JS Range Slider (with Progress)</title> </head> <body> <div class="row"> <div class="col-md-8 offset-md-2"> <h1 class="rangeSliderHeading mt-5 text-center">HTML/CSS/JS Range Slider (with Progress)</h1> <div class="rangeSliderMainDiv"> <div class="range-slider position-relative"> <p class="rangeSliderMiddleLine1"></p> <p class="rangeSliderMiddleLine2"></p> <div id="tooltip1" class="tooltips"></div> <input id="range1" class="range" type="range" value="60" min="0" max="200"> <p class="rangeSliderMiddleNum">100%</p> <p class="rangeSliderMiddleNumEnd">200%</p> </div> </div> </div> </div> </body> </html>
Copied
<!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"> <!-- bootstrap 5 CDN and css --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" integrity="sha512-Fo3rlrZj/k7ujTnHg4CGR2D7kSs0v4LLanw2qksYuRlEzO+tcaEPQogQ0KaoGN26/zrn20ImR1DfuLWnOo7aBA==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> <!-- google font and font awesome CDN --> <link href="https://fonts.googleapis.com/css2?family=Manrope:wght@200;300;400;500;600;700;800&family=Roboto&display=swap" rel="stylesheet"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" integrity="sha512-Fo3rlrZj/k7ujTnHg4CGR2D7kSs0v4LLanw2qksYuRlEzO+tcaEPQogQ0KaoGN26/zrn20ImR1DfuLWnOo7aBA==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <title>Simple HTML/CSS/JS Range Slider (with Progress)</title> </head> <body> <div class="row"> <div class="col-md-8 offset-md-2"> <h1 class="rangeSliderHeading mt-5 text-center">HTML/CSS/JS Range Slider (with Progress)</h1> <div class="rangeSliderMainDiv"> <div class="range-slider position-relative"> <p class="rangeSliderMiddleLine1"></p> <p class="rangeSliderMiddleLine2"></p> <div id="tooltip1" class="tooltips"></div> <input id="range1" class="range" type="range" value="60" min="0" max="200"> <p class="rangeSliderMiddleNum">100%</p> <p class="rangeSliderMiddleNumEnd">200%</p> </div> </div> </div> </div> </body> </html>
CSS
body { overflow: hidden; } .rangeSliderHeading{ color: rgb(6, 2, 114); } .rangeSliderMainDiv { height: 100vh; display: flex; align-items: center; } .range-slider { width: 100%; margin: 0 auto; position: relative; } .range-slider.disabled .tooltips span { display: none; } .range { -webkit-appearance: none; width: 100%; } .range:focus { outline: none; } .range::-webkit-slider-runnable-track { width: 100%; height: 4px; cursor: pointer; background: linear-gradient(90deg, #0E6651 var(--range-progress), #E9E9E9 var(--range-progress)); border-radius: 1rem; z-index: 1; } .range::-webkit-slider-thumb { -webkit-appearance: none; border-radius: 50%; background: #0E6651; cursor: pointer; height: 23px; width: 23px; transform: translateY(calc(-50%)); } .tooltips { position: absolute; top: -1.3rem; } .tooltips span { position: absolute; display: block; color: #0E6651; font-weight: 700; font-size: 13px; left: 50%; transform: translate(-50%, 0); } .tooltips span:after { content: "%"; } .rangeSelectorLabel { margin-bottom: 1rem; } .rangeSelectorLabel { margin-bottom: 1rem; } .rangeSliderMiddleNum { position: absolute; left: 50%; bottom: -2.2rem; transform: translateX(-50%); font-weight: 600; font-size: 11px; color: #CECECE; } .rangeSliderMiddleLine2 { position: absolute; width: 3px; height: 14px; background: #E9E9E9; border-radius: 5px; left: 50%; transform: translateX(-50%); right: 8px; bottom: -0.88rem; z-index: 0; } .rangeSliderMiddleLine1 { position: absolute; width: 3px; height: 14px; background: #E9E9E9; border-radius: 5px; right: 8px; bottom: -0.88rem; z-index: 0; } .rangeSliderMiddleNumEnd { position: absolute; right: 0; bottom: -2.2rem; font-weight: 600; font-size: 11px; color: #CECECE; }
Copied
body { overflow: hidden; } .rangeSliderHeading{ color: rgb(6, 2, 114); } .rangeSliderMainDiv { height: 100vh; display: flex; align-items: center; } .range-slider { width: 100%; margin: 0 auto; position: relative; } .range-slider.disabled .tooltips span { display: none; } .range { -webkit-appearance: none; width: 100%; } .range:focus { outline: none; } .range::-webkit-slider-runnable-track { width: 100%; height: 4px; cursor: pointer; background: linear-gradient(90deg, #0E6651 var(--range-progress), #E9E9E9 var(--range-progress)); border-radius: 1rem; z-index: 1; } .range::-webkit-slider-thumb { -webkit-appearance: none; border-radius: 50%; background: #0E6651; cursor: pointer; height: 23px; width: 23px; transform: translateY(calc(-50%)); } .tooltips { position: absolute; top: -1.3rem; } .tooltips span { position: absolute; display: block; color: #0E6651; font-weight: 700; font-size: 13px; left: 50%; transform: translate(-50%, 0); } .tooltips span:after { content: "%"; } .rangeSelectorLabel { margin-bottom: 1rem; } .rangeSelectorLabel { margin-bottom: 1rem; } .rangeSliderMiddleNum { position: absolute; left: 50%; bottom: -2.2rem; transform: translateX(-50%); font-weight: 600; font-size: 11px; color: #CECECE; } .rangeSliderMiddleLine2 { position: absolute; width: 3px; height: 14px; background: #E9E9E9; border-radius: 5px; left: 50%; transform: translateX(-50%); right: 8px; bottom: -0.88rem; z-index: 0; } .rangeSliderMiddleLine1 { position: absolute; width: 3px; height: 14px; background: #E9E9E9; border-radius: 5px; right: 8px; bottom: -0.88rem; z-index: 0; } .rangeSliderMiddleNumEnd { position: absolute; right: 0; bottom: -2.2rem; font-weight: 600; font-size: 11px; color: #CECECE; }
JS
const range1 = document.getElementById('range1'), tooltip1 = document.getElementById('tooltip1'), setValue1 = () => { const newValue1 = Number((range1.value - range1.min) * 100 / (range1.max - range1.min)), newPosition1 = 16 - (newValue1 * 0.32); tooltip1.innerHTML = `<span>${range1.value}</span>`; tooltip1.style.left = `calc(${newValue1}% + (${newPosition1}px))`; document.documentElement.style.setProperty("--range-progress", `calc(${newValue1}% + (${newPosition1}px))`); }; document.addEventListener("DOMContentLoaded", setValue1); range1.addEventListener('input', setValue1);
Copied
const range1 = document.getElementById('range1'), tooltip1 = document.getElementById('tooltip1'), setValue1 = () => { const newValue1 = Number((range1.value - range1.min) * 100 / (range1.max - range1.min)), newPosition1 = 16 - (newValue1 * 0.32); tooltip1.innerHTML = `<span>${range1.value}</span>`; tooltip1.style.left = `calc(${newValue1}% + (${newPosition1}px))`; document.documentElement.style.setProperty("--range-progress", `calc(${newValue1}% + (${newPosition1}px))`); }; document.addEventListener("DOMContentLoaded", setValue1); range1.addEventListener('input', setValue1);
Output
Our Courses
HTML 5
CSS
JavaScript
MySql
PHP
Laravel
Bootstrap
Programming Tutorial
PHP
JavaScript
HTML
Laravel
MySQL
JQuery
CSS
Git
Bootstrap
Vue JS
Android
Python
Server
Code Snippets
Chat Box
Range Slider
Radio Button
Select Box
Nav Bar
Other
Testimonial
Carousel
Logo
Loader
Lightbox
Forms
Popup
Table
HTML Course Code
HTML Entity
↑→ Arrows
$¢ Currency
Aö Letters
%+ Math
1¾ Numbers
&— Punctuation
©™ Symbols
Best Of
Internet
Technology
Health
Travel
Onine Tools
CSS Minifier
Text Converter
Age Calculator
Pincode Details
Whiteboard
PDF to Text
Gradient Generator
PX to REM Converter
REM to PX Converter
PX to EM Converter
EM to PX Converter
WEBP Converter
Latest & Upcoming movies
Bollywood
Hollywood
Tamil
Telgu
Bangla
Web Series
Notes
HTML
CSS
JS