-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
73 lines (70 loc) · 2.47 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="author" content="ZHAO Wenyi" />
<title>SJTU校庆头像生成 | By ZWY</title>
<style type="text/css">
html, body {
background-color: white;
position: relative;
width: 100%;
height: 100%;
}
#banner {
background-size:547px 548px;
background-repeat:no-repeat;
position: relative;
width:547px;
height: 548px;
}
#avatar {
background-size:316px 316px;
border-radius: 316px;
width: 316px;
height: 316px;
position: absolute;
/* z-index: 1; */
left: 114px;
top: 115px;
}
</style>
</head>
<body>
<div id="banner"></div>
<img id="avatar" src="" />
<br><br>
<form>
<p><input id="upload" type="file" name="file" /></p>
请选择校徽颜色:
<select id="bannerColor">
<option value="blue">蓝色</option>
<option value="red">红色</option>
<option value="gold">金色</option>
<option value="black">黑色</option>
<option value="green">绿色</option>
<option value="grey">灰色</option>
</select>
</form>
<p>暂时未提供一键保存功能,请网页截图后自行裁剪。</p>
<a href="https://github.com/PeggyZWY" target="_blank">来 GitHub 联系我 ⊙▽⊙</a>
<script type="text/javascript">
window.onload = function() {
var bannerDiv = document.getElementById("banner");
bannerDiv.style.backgroundImage = "url(sjtubanner_blue.png)";
var uploadBtn = document.getElementById("upload");
var bannerColorList = document.getElementById("bannerColor");
uploadBtn.addEventListener("change", function(event) {
var imgSrc = document.getElementById("upload").files[0];
var src = window.URL.createObjectURL(imgSrc);
document.getElementById("avatar").src = src;
}, false);
bannerColorList.addEventListener("change", function(event) {
var i = bannerColorList.selectedIndex;
var color = bannerColorList.options[i].value;
bannerDiv.style.backgroundImage = "url(sjtubanner_" + color + ".png)";
}, false);
}
</script>
</body>
</html>