Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
214 lines (200 loc) · 4.45 KB
/
Copy pathindex.html
File metadata and controls
214 lines (200 loc) · 4.45 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<title>模拟手机短信发送</title>
<style>
body,
p {
margin: 0;
}
input {
margin: 0;
padding: 0;
outline: none;
vertical-align: middle;
}
#wrap {
margin: 10px auto;
width: 320px;
background-color: #66efd7;
border: 3px solid #000;
border-radius: 20px;
padding: 20px;
box-sizing: border-box;
}
#content {
box-sizing: border-box;
height: 400px;
background-color: #fff;
overflow-y: auto;
padding: 10px;
}
#massage {
height: 50px;
background-color: #e3e3e3;
text-align: center;
}
#photo {
display: inline-block;
vertical-align: top;
width: 36px;
height: 40px;
margin: 5px;
}
.img {
background: url('img/img.png') no-repeat;
/* background-color: blue; */
}
.bgColor {
background: url('img/img2.png') no-repeat;
/* background-color: red; */
}
.contentTxt {
margin-top: 10px;
position: relative;
}
.left-span {
content: "";
position: absolute;
top: 0;
left: 0;
width: 36px;
height: 40px;
background: url('img/img.png') no-repeat;
}
.right-span {
content: "";
position: absolute;
top: 0;
right: 0;
width: 36px;
height: 40px;
background: url('img/img2.png') no-repeat;
}
/* .contentTxt:nth-of-type(2n) {
text-align: left;
}
.contentTxt:nth-of-type(2n-1) {
text-align: right;
} */
strong {
display: inline-block;
vertical-align: top;
font-weight: normal;
font-size: 14px;
line-height: 24px;
padding: 8px;
border-radius: 5px;
word-break: break-all;
}
.left-txts {
background-color: #ccc;
margin-left: 45px;
}
.right-txts {
background-color: palevioletred;
margin-right: 45px;
float: right;
}
/* .contentTxt:nth-of-type(2n) strong {
background-color: palevioletred;
color: #fff;
}
.contentTxt:nth-of-type(2n-1) strong {
background-color: #ccc;
color: #000;
} */
em {
position: absolute;
top: 15px;
width: 0;
height: 0;
border: 5px solid transparent;
}
.left-em {
left: 35px;
border-right-color: #ccc;
}
.right-em {
right: 35px;
border-left-color: palevioletred;
}
/* .contentTxt:nth-of-type(2n) em {
border-right-color: palevioletred;
}
.contentTxt:nth-of-type(2n-1) em {
border-left-color: #ccc;
} */
#txt {
border: none;
width: 150px;
height: 30px;
border-radius: 5px;
padding: 4px 10px;
box-sizing: border-box;
font-size: 14px;
line-height: 22px;
}
#btn {
border: none;
background-color: transparent;
color: #d25a61;
font-size: 16px;
line-height: 50px;
font-family: "微软雅黑";
margin-left: 10px;
}
.clearFix:after {
content: "";
display: block;
clear: both;
}
</style>
</head>
<body>
<div id="wrap">
<div id="content"></div>
<div id="massage">
<span id="photo" class="img"></span>
<input type="text" id="txt">
<input type="button" value="发送" id="btn">
</div>
</div>
<script>
var content = document.getElementById("content");
var photo = document.getElementById("photo");
var txt = document.getElementById("txt");
var btn = document.getElementById("btn");
photo.onclick = function(){
if(photo.className == "img"){
photo.className = "bgColor";
} else {
photo.className = "img";
}
};
btn.onclick = function(){
console.log(photo.className);
if(txt.value == ""){
alert('亲,写点什么吧!');
} else {
content.innerHTML = '<p class="contentTxt clearFix"><span id="span-ele"></span><em id="em-ele"></em><strong id="strong-ele">' + txt.value + '</strong>' + '</p>' + content.innerHTML ;
txt.value = "";
var oStrong = document.getElementById("strong-ele");
var oEm = document.getElementById("em-ele");
var oSpan = document.getElementById("span-ele");
if(photo.className=="bgColor"){ //红人
oStrong.className = "right-txts";
oSpan.className = "right-span";
oEm.className = "right-em";
}else {//蓝人
oStrong.className = "left-txts";
oSpan.className = "left-span";
oEm.className = "left-em";
}
}
};
</script>
</body>
</html>