-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrectCreator.html
More file actions
83 lines (67 loc) · 2.55 KB
/
rectCreator.html
File metadata and controls
83 lines (67 loc) · 2.55 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
<!DOCTYPE html>
<html>
<body style="background-color:dimgrey">
<style>
svg {
background-color: transparent;
position: absolute;
top: 60px;
}
button {
width: 160px;
height: 35px;
top: 10px;
left: 10px;
background-color: rgb(128,128, 128,0.1);
font-size: 20px;
font-family: Segoe UI;
font-weight: 100;
position: absolute;
color: white;
}
</style>
<button onclick="crEl()">Создать кнопку</button>
<svg id="svg" xmlns="http://www.w3.org/2000/svg"></svg>
<script>
var svg = document.getElementById("svg");
var nx = 0;
var ny = 1;
svg.setAttribute('width', 94 + '%');
svg.setAttribute('height', 500 + 'px');
createElem(15, 10, 70, 28, "Домой", "index.html")
function crEl() {
if ((40 * ny + 10) > 150) {
nx++;
ny = 1;
}
createElem(80 * nx + 15, 40 * ny + 10, 70, 28, nx + " " + ny, "index.html");
ny++;
}
function createElem(x, y, w, h, text, ref) {
var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
rect.setAttribute("width", w);
rect.setAttribute("height", h);
rect.setAttribute("x", x);
rect.setAttribute("y", y);
rect.setAttribute("style", "fill:black; filter:blur(1px)");
var rect1 = document.createElementNS("http://www.w3.org/2000/svg", "rect");
rect1.setAttribute("width", w);
rect1.setAttribute("height", h);
rect1.setAttribute("x", x);
rect1.setAttribute("y", y);
rect1.setAttribute("style", "fill:#696969; cursor:pointer;");
if (ref != "") rect1.onclick = function () { location.replace(ref); }
var textline = document.createElementNS("http://www.w3.org/2000/svg", "text");
textline.setAttribute("x", x + 5);
textline.setAttribute("y", y + 20);
textline.setAttribute("style", "font-size:20px; font-family:Segoe UI; fill:white; font-weight:100; cursor:pointer;")
textline.textContent = text;
if (ref != "") textline.onclick = function () { location.replace(ref); }
svg.appendChild(rect);
svg.appendChild(rect1);
svg.appendChild(textline);
document.body.appendChild(svg);
}
</script>
</body>
</html>