用HTML写一个好看的人工客服聊天框
时间: 2023-10-15 09:05:44 浏览: 31
好的,下面是一个简单的 HTML 人工客服聊天框的代码示例:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>人工客服</title>
<style>
* {
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
.chatbox {
max-width: 700px;
margin: 50px auto;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
overflow: hidden;
}
.chatbox-header {
background-color: #007bff;
color: #fff;
padding: 10px;
text-align: center;
font-weight: bold;
font-size: 20px;
}
.chatbox-body {
height: 400px;
overflow-y: scroll;
padding: 10px;
}
.chatbox-message {
padding: 10px;
margin: 10px;
border-radius: 10px;
font-size: 18px;
line-height: 1.5;
clear: both;
position: relative;
}
.chatbox-message-user {
background-color: #007bff;
color: #fff;
float: left;
}
.chatbox-message-server {
background-color: #f2f2f2;
color: #555;
float: right;
}
.chatbox-message:before {
content: "";
position: absolute;
border-style: solid;
border-width: 10px 10px 10px 0;
border-color: transparent;
}
.chatbox-message-user:before {
left: -10px;
border-right-color: #007bff;
}
.chatbox-message-server:before {
right: -10px;
border-left-color: #f2f2f2;
}
.chatbox-input {
padding: 10px;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
background-color: #f2f2f2;
}
.chatbox-input input[type="text"] {
border: none;
border-radius: 5px;
padding: 10px;
font-size: 18px;
flex-grow: 1;
margin-right: 10px;
}
.chatbox-input button[type="submit"] {
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
font-size: 18px;
padding: 10px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.chatbox-input button[type="submit"]:hover {
background-color: #0062cc;
}
</style>
</head>
<body>
<div class="chatbox">
<div class="chatbox-header">人工客服</div>
<div class="chatbox-body">
<div class="chatbox-message chatbox-message-server">您好,有什么可以帮您的吗?</div>
</div>
<div class="chatbox-input">
<input type="text" placeholder="请输入您的问题...">
<button type="submit">发送</button>
</div>
</div>
</body>
</html>
```
该示例包含一个聊天框的头部、消息列表和输入框。消息列表中包含两种类型的消息:用户发送的消息和客服回复的消息,它们分别使用不同的样式进行区分,同时还包括一个箭头效果,使得消息更加好看。整个聊天框的样式也比较美观,适合用于实际的网站中。