-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexmaple-vertical-ajust-usage.html
85 lines (71 loc) · 1.81 KB
/
exmaple-vertical-ajust-usage.html
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="jquery.verticalAjust.js"></script>
<body>
<div class="list">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<style>
.item {
/* same width */
width: 150px;
display: inline-block; /* important! */
vertical-align: top; /* important! */
height: 100px;
margin: 10px;
text-align: center;
background: rgba(0, 128, 0, 0.5);
font-size: 40px;
}
</style>
<script>
(function ($) {
/* Prepare sample list.
Add random height and number labels.
*/
$(".item").each(function(index) {
var ht = getRandomInt(5, 15) * 10;
$(this).css({'height' : ht, 'lineHeight' : ht + 'px' }).html(index);
});
function getRandomInt(min, max)
{
return Math.floor(Math.random() * (max - min + 1)) + min;
}
/* plugin usage */
$.fn.verticalAjust('attach', '.list .item');
}) (jQuery);
</script>
</body>
</html>