Skip to content

Instantly share code, notes, and snippets.

@baniol
Created April 5, 2014 20:07
Show Gist options
  • Save baniol/9997455 to your computer and use it in GitHub Desktop.
Save baniol/9997455 to your computer and use it in GitHub Desktop.
html5 slider range css
<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
body {
padding-top: 200px;
}
input::after {
content: attr(data-value) '/' attr(max);
position: relative;
left: 135px; top: -20px;
}
</style>
</head>
<body>
<h2>from: http://www.htmlfivecan.com/#23</h2>
<input type="range" min="0" max="100" value="25">
<script>
var input = document.querySelector('input');
input.dataset.value = input.value; // Set an initial value.
input.addEventListener('change', function(e) {
this.dataset.value = this.value;
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment