-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestMasonry.html
More file actions
104 lines (80 loc) · 2.44 KB
/
testMasonry.html
File metadata and controls
104 lines (80 loc) · 2.44 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Multi-column Layout</title>
<link href="https://cdn.jsdelivr.net/npm/layui@2.9.18/dist/css/layui.min.css" rel="stylesheet">
<script src="https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.js"></script>
<style>
html, body {
margin: 0;
padding: 0;
font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
font-size: 14px;
/*overflow-y: hidden;*/
overflow-x: hidden;
}
#calendar {
max-width: 1100px;
margin: 40px auto;
width:80% ;
}
.grid-item { width: 200px; }
.grid-item--width2 { width: 400px; }
#idBlock1{
height:200px ;
background-color: aqua;
}
#idBlock2{
height:400px ;
background-color: black;
}
#idBlock3{
height:100px ;
background-color: blue;
}
</style>
</head>
<body>
<div class="grid">
<div class="grid-item" id="idBlock1">.dsfdsfds..</div>
<div class="grid-item grid-item--width2" id="idBlock2">.fdsfds..</div>
<div class="grid-item" id="idBlock3">.fdsfds..</div>
</div>
<script>
function getRandomColor() {
var letters = '0123456789ABCDEF';
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
var elem = document.querySelector('.grid');
// element argument can be a selector string
// for an individual element
/*
var msnry = new Masonry( '.grid', {
// options
});
*/
for(let i=0;i<20;i++){
let tagBlock = document.createElement('div') ;
//grid-item
tagBlock.classList.add('grid-item') ;
let nHeight=Math.round(Math.random()*500) ;
tagBlock.style.height=`${nHeight}px` ;
tagBlock.innerText=`Block:${i},h:${nHeight}`;
//$("#colorpad").css("background-color", getRandomColor());
tagBlock.style.backgroundColor = getRandomColor() ;
elem.appendChild(tagBlock) ;
}
var msnry = new Masonry( elem, {
// options
itemSelector: '.grid-item',
columnWidth: 200
});
</script>
</body>
</html>