Slider
How do I make an slider?
What is a slider? How do you make a slider? This script and codes were developed by Hampus Persson on 13 September 2022, Tuesday.
Slider - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Slider</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel='stylesheet prefetch' href='https://files.anpdm.com/tenko-core.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="container"> <header> <h1>Attributions</h1> <p>Explanatory text about this awesome feature.</p> </header> <div class="Slider-wrapper"> <div id="js-Slider-value" class="Slider-value">1</div> <input id="js-Slider" min=0 max=10 step="1" class="Slider" type="range" value=0> <div class="Slider-range--min">0</div> <div class="Slider-range--max">10</div> </div> <footer> <button class="a_Button-secondary">View log</button> </footer>
</div> <script src="js/index.js"></script>
</body>
</html>
Slider - Script Codes CSS Codes
.Slider { width: 100%; -webkit-appearance: none; width: 100%; background: transparent; margin-top: 44px;
}
.Slider::-webkit-slider-thumb { -webkit-appearance: none; border: 3px solid #fff; height: 18px; width: 18px; border-radius: 4px; background: #eca15f; cursor: pointer; margin-top: -6px; /* You need to specify a margin in Chrome, but in Firefox and IE it is automatic */
}
.Slider::-webkit-slider-runnable-track { width: 100%; height: 5px; cursor: pointer; background: #eca15f; border-radius: 4px;
}
.Slider:focus { outline: none;
}
.Slider:focus::-webkit-slider-thumb { box-shadow: 0 0 4px 2px rgba(0,0,0,0.4);
}
.Slider:active { outline: none;
}
.Slider:active::-webkit-slider-thumb { box-shadow: 0 0 4px 2px rgba(0,0,0,0.4); background-color: #c56716;
}
.Slider-value { position: absolute; line-height: 30px; padding: 0 6px; min-width: 30px; border-radius: 4px; text-align: center; border: 1px solid #eca15f;
}
.Slider-value:after,
.Slider-value:before { top: 100%; left: 50%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none;
}
.Slider-value:after { border-color: rgba(255,255,255,0); border-top-color: #fff; border-width: 4px; margin-left: -4px;
}
.Slider-value:before { border-color: rgba(236,161,95,0); border-top-color: #eca15f; border-width: 5px; margin-left: -5px;
}
.Slider-wrapper { position: relative; width: 100%; height: 80px; margin-bottom: 24px;
}
.Slider-range--min { position: absolute; bottom: 0; left: 0;
}
.Slider-range--max { position: absolute; bottom: 0; right: 0;
}
.container { width: 650px; background-color: #fff; padding: 20px 60px; min-height: 100px;
}
header { text-align: center; margin-bottom: 24px;
}
h1 { margin-bottom: 6px;
}
body { background-color: #ccc; padding: 20px; box-sizing: border-box;
}
Slider - Script Codes JS Codes
'use strict';
console.clear();
var Value = document.getElementById('js-Slider-value');
var Slider = document.getElementById('js-Slider');
var width = undefined;
Slider.addEventListener('input', positionValue);
document.addEventListener('DOMContentLoaded', positionValue);
function positionValue() { width = width || Slider.offsetWidth; var newPoint = keepInRange((Slider.value - Slider.getAttribute("min")) / (Slider.getAttribute("max") - Slider.getAttribute("min"))); var newPlace = width * newPoint; var ValueWidth = Value.offsetWidth; var SliderThumbWidth = 18; var offset = newPoint * SliderThumbWidth + (ValueWidth - SliderThumbWidth) / 2; Value.style.left = newPlace - offset + "px"; Value.innerHTML = Slider.value;
}
function keepInRange(number, min, max) { return number < min ? min : number > max ? max : number;
}
![Slider - Script Codes](http://shots.codepen.io/hmps/pen/kkWpdm-512.jpg)
Developer | Hampus Persson |
Username | hmps |
Uploaded | September 13, 2022 |
Rating | 3 |
Size | 4,088 Kb |
Views | 24,288 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Slide like Mailbox | 3,758 Kb |
Drag and drop editor | 3,422 Kb |
Dropdown | 4,452 Kb |
JSCSS | 3,963 Kb |
Drill down table | 2,989 Kb |
Badge animation | 2,732 Kb |
Test for pseudo element animation | 3,306 Kb |
Pulsating heart | 2,765 Kb |
Pretty inputs | 2,773 Kb |
Filter list | 3,517 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
A Pen by Alexandru Pora | Axpro | 1,615 Kb |
Sassy Buttons | Elyseholladay | 2,299 Kb |
Sticky notes with CSS3 | HaiNguyen007 | 2,146 Kb |
Weather App 2 | MightyJoeW | 2,877 Kb |
Sticky div | Kaslab | 2,225 Kb |
Animating characters with jQuery | 042 | 2,776 Kb |
Fun form with currentColor | Bnthor | 2,713 Kb |
Canvas Orbital Trails v2 | Jackrugile | 3,421 Kb |
Right Click Menu | Anodpixels | 2,252 Kb |
Ipad Mini Showcase | Hornebom | 10,479 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!