Skip to content

Instantly share code, notes, and snippets.

@ryndel ryndel/meter.html
Last active Dec 22, 2015

What would you like to do?
A simple html clickable meter
<!doctype html>
<meta charset="UTF-8">
*, *:before, *:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
div#weight {
padding: 10px;
background-color: #fafafa;
width: 220px;
div.meter-container {
width: 0%;
position: relative;
background-color: #0F0;
height: 15px;
background-color: #428bca;
ul.meter {
position: absolute;
top: 0;
left: 0;
margin: 0;
padding: 0;
list-style-type: none;
width: 200px;
background-color: rgba(0,0,0,.1)
ul.meter li {
float: left;
width: 10%;
height: 15px;
border: 1px solid #fff;
border-collapse: collapse;
<div id="weight">
<div class="meter-container">
<ul class="meter">
<li class="1"></li>
<li class="2"></li>
<li class="3"></li>
<li class="4"></li>
<li class="5"></li>
<li class="6"></li>
<li class="7"></li>
<li class="8"></li>
<li class="9"></li>
<li class="10"></li>
<script src="//"></script>
$(document).ready(function() {
$(".meter li").click(function() {
var amt = $(this).attr('class') * 10;
$(this).closest(".meter-container").css( "width", amt +"%" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.