-
Notifications
You must be signed in to change notification settings - Fork 0
/
图片上传剪裁.html
89 lines (88 loc) · 2.54 KB
/
图片上传剪裁.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
<!DOCTYPE html>
<html>
<head>
<title>截图上传</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<style type="text/css">
*{margin: 0;padding: 0}
.cut-box{
margin: 50px auto 0;
width: 80%;
text-align: center;
}
.cut-div{
width: 600px;
height: 600px;
position: relative;
border: 1px solid #d2d3d2;
margin: auto;
-webkit-user-select: none; /* Chrome/Safari/Opera */
-khtml-user-select: none; /* Konqueror */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
not supported by any browser */
}
.cut-div>img{
position: absolute;
left: 0;
top: 0;
z-index: 10;
}
.move-div{
position: absolute;
left: 0;
top: 0;
z-index: 50;
width: 200px;
height: 200px;
border: 1px dashed #3fe;
cursor: move;
overflow: hidden;
}
.move-div>img{
position: absolute;
left: -1px;
top: -1px;
z-index: 10;
}
.cut-bg{
position: absolute;
left: 0;
top: 0;
z-index: 15;
width: 100%;
height: 100%;
background: #000;
opacity: 0.4;
}
.js-up-input{
display: inline-block;
width: 300px;
border:1px solid #000;
background: transparent;
opacity: 1;
}
</style>
</head>
<body>
<section class="cut-box js-cut-box">
<input class="js-up-input" type="file" name="pic" accept="image/*">
<button class="js-get-data-btn">获取数据</button>
<div class="cut-div js-cut-div">
<img class="js-show-pic" src="">
<div class="cut-bg"></div>
<div class="move-div js-move-ele">
<img class="js-top-pic" src="" ondragstart="return false">
</div>
</div>
</section>
<script type="text/javascript" src="src/js/cut-pic.1.0.js"></script>
<script type="text/javascript">
window.onload=function(){
var cut_pic=new cutPic(".js-cut-box");
}
</script>
</body>
</html>