<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML5实现微信聊天气泡效果</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<link rel="stylesheet" href="chatbox.css">
</head>
<style>
body{
background-color: #ebebeb;
font-family: -apple-system;
font-family: "-apple-system", "Helvetica Neue", "Roboto", "Segoe UI", sans-serif;
}
.chat-sender{
clear:both;
font-size: 80%;
}
.chat-sender div:nth-of-type(1){
float: left;
}
.chat-sender div:nth-of-type(2){
margin: 0 50px 2px 50px;
padding: 0px;
color: #848484;
font-size: 70%;
text-align: left;
}
.chat-sender div:nth-of-type(3){
background-color: white;
/*float: left;*/
margin: 0 50px 10px 50px;
padding: 10px 10px 10px 10px;
border-radius:7px;
text-indent: -12px;
}
.chat-receiver{
clear:both;
font-size: 80%;
}
.chat-receiver div:nth-of-type(1){
float: right;
}
.chat-receiver div:nth-of-type(2){
margin: 0px 50px 2px 50px;
padding: 0px;
color: #848484;
font-size: 70%;
text-align: right;
}
.chat-receiver div:nth-of-type(3){
/*float:right;*/
background-color: #b2e281;
margin: 0px 50px 10px 50px;
padding: 10px 10px 10px 10px;
border-radius:7px;
}
.chat-receiver div:first-child img,
.chat-sender div:first-child img{
width: 40px;
height: 40px;
/*border-radius: 10%;*/
}
.chat-left_triangle{
height: 0px;
width: 0px;
border-width: 6px;
border-style: solid;
border-color: transparent white transparent transparent;
position: relative;
left: -22px;
top: 3px;
}
.chat-right_triangle{
height: 0px;
width: 0px;
border-width: 6px;
border-style: solid;
border-color: transparent transparent transparent #b2e281;
position: relative;
right:-22px;
top:3px;
}
.chat-notice{
clear: both;
font-size: 70%;
color: white;
text-align: center;
margin-top: 15px;
margin-bottom: 15px;
}
.chat-notice span{
background-color: #cecece;
line-height: 25px;
border-radius: 5px;
padding: 5px 10px;
}
</style>
<body>
<!-- Left -->
<div class="chat-sender">
<div><img src="img/ben.png"></div>
<div>Tom</div>
<div>
<div class="chat-left_triangle"></div>
<span> hello hello hello hello hello hello hello hello</span>
</div>
</div>
<!-- Right -->
<div class="chat-receiver">
<div><img src="img/max.png"></div>
<div>Max</div>
<div>
<div class="chat-right_triangle"></div>
<span> hello world。</span>
</div>
</div>
<!-- Right -->
<div class="chat-sender">
<div><img src="img/adam.jpg"></div>
<div>Adam</div>
<div>
<div class="chat-left_triangle"></div>
<span> hello hellohello hellohello hellohello hellohello hello</span>
</div>
</div>
<!-- Notice/Center -->
<div class="chat-notice">
<span>2017年12月10日 23:13</span>
</div>
<!-- Left -->
<div class="chat-sender">
<div><img src="img/perry.png"/></div>
<div>Perry</div>
<div>
<div class="chat-left_triangle"></div>
<span> hello hellohello hellohello hellohello hellohello hellohello hellohello hellohello hello</span>
</div>
</div>
<!-- Left -->
<div class="chat-sender">
<div><img src="img/mike.png"></div>
<div>Mike</div>
<div>
<div class="chat-left_triangle"></div>
<span> hello hellohello hellohello hellohello hellohello hellohello hello</span>
</div>
</div>
<!-- Right -->
<div class="chat-receiver">
<div><img src="img/max.png"></div>
<div>June</div>
<div>
<div class="chat-right_triangle"></div>
<span> hello hellohello hellohello hello</span>
</div>
</div>
<!-- Notice/Center -->
<div class="chat-notice">
<span>你被群主移除群聊</span>
</div>
</body>
</html>
网友评论