Небольшой эквалайзер своими руками)
| JavaScript | 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
| <script>
$(document).ready(function(){
var random;
var minus;
/* Рандомные числа для каждого блока */
var random1 = 0;
var random2 = 0;
var random3 = 0;
var random4 = 0;
var random5 = 0;
var random6 = 0;
/* Шаг уменьшения\увеличения в пикселях*/
var crok = 1;
/* Запуск каждого блока */
setInterval(music1,100);
setInterval(music2,100);
setInterval(music3,100);
setInterval(music4,100);
setInterval(music5,100);
setInterval(music6,100);
/* Функция "проигрывания" для первого блока*/
function music1(){
if (random1 == 0) /* Если рандомное число равно 0, сгенерируем новое */
random1 = rand1();
index = 0; /* Индекс элемента на странице */
style = $("#main div").eq(index).attr("style").split("height:"); /* Получаем высоту блока */
style = style[1].split("px"); /*Отделяем цифровое значение от пикселей*/
if(style[0] < random1) /* Если высота блока меньше рандомного числа, увеличиваем её*/
style[0] = parseInt(style[0]) + parseInt(crok);
else if(style[0] > random1) /* Если высота блока больше рандомного числа, уменьшаем её*/
style[0] = style[0] - crok;
$("#main div").eq(index).attr("style","height:"+style[0]+"px")
if(style[0] == random1) /* При достижении высотой рандомного числа, сбрасываем его в 0*/
random1 = 0;
}
/*Функция рандомизации числа*/
function rand1(){
random1 = Math.floor(Math.random()*10)+10;
/*Запускаем проверку рандомного числа, т.к. оно не должно быть больше высоты блока*/
random1 = prov(random1);
return random1;
}
/* Функция "проигрывания" для второго блока*/
function music2(){
if (random2 == 0)
random2 = rand2();
index = 1;
style = $("#main div").eq(index).attr("style").split("height:");
style = style[1].split("px");
if(style[0] < random2)
style[0] = parseInt(style[0]) + parseInt(crok);
else if(style[0] > random2)
style[0] = style[0] - crok;
$("#main div").eq(index).attr("style","height:"+style[0]+"px")
if(style[0] == random2)
random2 = 0;
}
function rand2(){
random2 = Math.floor(Math.random()*10)+10;
random2 = prov(random2);
return random2;
}
function music3(){
if (random3 == 0)
random3 = rand3();
index = 2;
style = $("#main div").eq(index).attr("style").split("height:");
style = style[1].split("px");
if(style[0] < random3)
style[0] = parseInt(style[0]) + parseInt(crok);
else if(style[0] > random3)
style[0] = style[0] - crok;
$("#main div").eq(index).attr("style","height:"+style[0]+"px")
if(style[0] == random3)
random3 = 0;
}
function rand3(){
random3 = Math.floor(Math.random()*10)+10;
random3 = prov(random3);
return random3;
}
function music4(){
if (random4 == 0)
random4 = rand4();
index = 3;
style = $("#main div").eq(index).attr("style").split("height:");
style = style[1].split("px");
if(style[0] < random4)
style[0] = parseInt(style[0]) + parseInt(crok);
else if(style[0] > random4)
style[0] = style[0] - crok;
$("#main div").eq(index).attr("style","height:"+style[0]+"px")
if(style[0] == random4)
random4 = 0;
}
function rand4(){
random4 = Math.floor(Math.random()*10)+10;
random4 = prov(random4);
return random4;
}
function music5(){
if (random5 == 0)
random5 = rand5();
index = 4;
style = $("#main div").eq(index).attr("style").split("height:");
style = style[1].split("px");
if(style[0] < random5)
style[0] = parseInt(style[0]) + parseInt(crok);
else if(style[0] > random5)
style[0] = style[0] - crok;
$("#main div").eq(index).attr("style","height:"+style[0]+"px")
if(style[0] == random5)
random5 = 0;
}
function rand5(){
random5 = Math.floor(Math.random()*10)+10;
random5 = prov(random5);
return random5;
}
function music6(){
if (random6 == 0)
random6 = rand6();
index = 5;
style = $("#main div").eq(index).attr("style").split("height:");
style = style[1].split("px");
if(style[0] < random6)
style[0] = parseInt(style[0]) + parseInt(crok);
else if(style[0] > random6)
style[0] = style[0] - crok;
$("#main div").eq(index).attr("style","height:"+style[0]+"px")
if(style[0] == random6)
random6 = 0;
}
function rand6(){
random6 = Math.floor(Math.random()*10)+10;
random6 = prov(random6);
return random6;
}
/* Функция проверки рандомного числа */
function prov(random){
if(random >= 30){
random = Math.floor(Math.random()*10)+10;
prov(random);
}
return random;
}
})
</script> |
|
| CSS | 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
| <style>
body{
text-align:center;
margin:0 auto;
}
div{
background: #E7E7E7; /* Для старых браузров */
background: -moz-linear-gradient(top, #E7E7E7, #000000); /* Firefox 3.6+ */
/* Chrome 1-9, Safari 4-5 */
background: -webkit-gradient(linear, left top, left bottom,
color-stop(0%,#E7E7E7), color-stop(100%,#000000));
/* Chrome 10+, Safari 5.1+ */
background: -webkit-linear-gradient(top, #E7E7E7, #000000);
background: -o-linear-gradient(top, #E7E7E7, #000000); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #E7E7E7, #000000); /* IE10 */
background: linear-gradient(top, #E7E7E7, #000000); /* CSS3 */
display:inline-block;
position:absolute;
width:5px;
bottom:0;
}
#main{
display:block;
height:30px;
width:40%;
background:white;
position:relative;
margin: 20% 50%;
}
#first{
left:0px;
}
#second{
left:7px;
}
#third{
left:14px;
}
#fourth{
left:21px;
}
#fiveth{
left:28px;
}
#sexth{
left:35px;
}
</style> |
|
| HTML5 | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<div id="main">
<div id="first" style="height:30px;"></div>
<div id="second" style="height:30px;"></div>
<div id="third" style="height:30px;"></div>
<div id="fourth" style="height:30px;"></div>
<div id="fiveth" style="height:30px;"></div>
<div id="sexth" style="height:30px;"></div>
</div>
</body>
</html> |
|
|