forked from S-mohan/color-picker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
104 lines (94 loc) · 3.07 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
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">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>如何实现一个颜色选择器 | 水墨寒的博客</title>
<meta name=keywords content=color-picker,颜色选择器,色相,hsv,rgb2hsv>
<meta name=description
content="Photoshop的颜色选择器是如何实现的?如何实现一个基于HSV模式的颜色选择器?如何使用JavaScript实现一个颜色选择?rgb转hsv,hsv转rgb, hex转rgb, hsv转hex, hex 转hsl smohan.net/blog/d5uvpu">
<link rel="stylesheet" href="../dist/mo.color-picker.css">
<style>
* {
box-sizing: border-box;
}
body {
padding: 2rem;
text-align: center;
font: 14px / 1.5 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'WenQuanYi Micro Hei', 'Microsoft Yahei', Arial, sans-serif;
}
.demo-box {
display: grid;
grid-template-columns: 280px 1fr;
grid-gap: 20px;
max-width: 1000px;
margin: 10px auto;
border: 1px solid #ccc;
}
.demo,
.demo-result {
padding: 10px;
text-align: left;
}
.demo-result li {
display: flex;
align-items: center;
line-height: 20px;
}
.color-block {
display: inline-block;
width: 16px;
height: 16px;
margin: 0 10px 0 0;
background: transparent;
position: relative;
}
.color-block::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: linear-gradient(45deg, #c5c5c5 25%, transparent 0, transparent 75%, #c5c5c5 0, #c5c5c5), linear-gradient(45deg, #c5c5c5 25%, transparent 0, transparent 75%, #c5c5c5 0, #c5c5c5);
background-size: 10px 10px;
background-position: 0 0, 5px 5px;
z-index: -1;
}
.gitbtns {
margin: 10px auto;
text-align: center;
}
.gitbtns iframe {
display: inline;
max-width: 120px;
}
</style>
</head>
<body>
<h1>如何实现一个颜色选择器</h1>
<p>项目地址:<a href="https://github.com/S-mohan/color-picker" target="_blank">https://github.com/S-mohan/color-picker</a>
<p>文章地址:<a href="https://smohan.net/blog/d5uvpu" target="_blank">https://smohan.net/blog/d5uvpu</a></p>
</p>
<div class="gitbtns">
<iframe src="https://ghbtns.com/github-btn.html?user=S-mohan&repo=color-picker&type=star&count=true" frameborder="0"
scrolling="0" height="20px"></iframe>
<iframe src="https://ghbtns.com/github-btn.html?user=S-mohan&repo=color-picker&type=fork&count=true" frameborder="0"
scrolling="0" height="20px"></iframe>
</div>
<div class="demo-box">
<div class="demo">
<div id="demo1"></div>
</div>
<div class="demo-result" id="demo1-result"></div>
</div>
<div class="demo-box">
<div class="demo">
<div id="demo2"></div>
</div>
<div class="demo-result" id="demo2-result"></div>
</div>
<script type="module" src="./index.js"></script>
</body>
</html>