-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_css.html
More file actions
87 lines (74 loc) · 2.43 KB
/
Copy pathtest_css.html
File metadata and controls
87 lines (74 loc) · 2.43 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
<!DOCTYPE html>
<html>
<head>
<title>Styling Div with CSS</title>
<style>
#license-plate-container {
display: flex;
flex-wrap: wrap;
}
.license-plate-group {
display: flex;
align-items: center;
margin-right: 10px; /* Adjust spacing between groups if desired */
padding: 5px;
border-radius: 5px;
border: 5px solid darkblue;
background-color: white;
color: darkblue;
font-weight: bold;
white-space: nowrap;
font-family: Verdana, sans-serif;
}
.license-plate-group span {
padding-left: 5px;
padding-right: 5px;
}
.license-plate-group .spacer {
display: inline-block;
width: 0.01ch; /* Adjust as needed */
height: 0.9em; /* Matches the height of the letters */
background-color: lightblue;
margin: 0 1px; /* Adjust as needed */
}
</style>
<script>
function getRandomColor() {
var letters = '0123456789ABCDEF';
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
function createChunkElements(chunks) {
var container = document.getElementById('license-plate-container');
chunks.forEach(function(chunk) {
var groupElement = document.createElement('div'); // Add a <div> element for each group
groupElement.classList.add('license-plate-group');
var lettersElement = document.createElement('span');
lettersElement.textContent = chunk.substr(0,3);
groupElement.appendChild(lettersElement);
var spacerElement = document.createElement('span');
spacerElement.classList.add('spacer');
spacerElement.style.backgroundColor = getRandomColor();
groupElement.appendChild(spacerElement);
var numbersElement = document.createElement('span');
numbersElement.textContent = chunk.substr(3,2);
groupElement.appendChild(numbersElement);
container.appendChild(groupElement); // Append the license plate to the container
});
}
window.onload = function() {
var chunksString = 'HAM80 RGA00 RIP12 ZAK00 KAK01 ABC11';
var chunks = chunksString.split(' ');
createChunkElements(chunks);
};
</script>
</head>
<body>
<div id="license-plate-container">
<!--<div class="license-plate-group"><span>TOM</span><span class="spacer"></span><span>45</span></div>-->
</div>
</body>
</html>