-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
59 lines (53 loc) · 1.4 KB
/
index.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
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Color Picker</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
background-color: #f4f4f4;
}
.color-box {
width: 200px;
height: 200px;
border: 2px solid #000;
margin-top: 20px;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
color: #000;
}
</style>
</head>
<body>
<h1>Color Picker</h1>
<input type="color" id="colorPicker">
<div id="colorBox" class="color-box">
Wähle eine Farbe
</div>
<script>
class ColorPicker {
constructor(colorPickerElement, colorBoxElement) {
this.colorPickerElement = colorPickerElement;
this.colorBoxElement = colorBoxElement;
this.colorPickerElement.addEventListener('input', this.updateColor.bind(this));
}
updateColor() {
const chosenColor = this.colorPickerElement.value;
this.colorBoxElement.style.backgroundColor = chosenColor;
this.colorBoxElement.textContent = chosenColor;
}
}
const colorPicker = new ColorPicker(document.getElementById('colorPicker'), document.getElementById('colorBox'));
</script>
</body>
</html>