"Bootstrap Street Lights click to activate the light"
Bootstrap 3.3.0 Snippet by cleonr8

1
2
3
4
5
6
7
8
9
10
11
12
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<div class="light row">
<div class="lights redlight col-md-1"></div>
<div class="lights orangelight col-md-1"></div>
<div class="lights greenlight col-md-1"></div>
</div>
</div>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*! Light */
.light {
background-color: whitesmoke;
box-shadow: 0 0 5px rgba(0,0,0, .8);
overflow: hidden;
padding: 0 0 4px;
width: 140px;
}
.light div {
border-radius: 50px;
display: block;
height: 30px;
margin: 4px auto 0;
opacity: .1;
width: 30px;
padding-left: 30px;
}
/*! Light colours */
.redlight {
background-color: red;
}
.orangelight {
background-color: orange;
}
.greenlight {
background-color: green;
}
/*! Active states */
.light div.active {
opacity: 1;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
$(document).ready(function () {
$('.light div').on('click', function () {
$(".lights").removeClass('active');
$(this).addClass("active");
});
});
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: