html写一个对话框界面
时间: 2023-07-01 17:09:37 浏览: 77
可以使用HTML和CSS来创建一个简单的对话框界面,以下是一个基本的示例:
```html
<!DOCTYPE html>
<html>
<head>
<title>对话框</title>
<style>
body {
background-color: #f5f5f5;
font-family: Arial, sans-serif;
}
.container {
width: 80%;
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
box-shadow: 0 0 10px rgba(0,0,0,0.2);
border-radius: 10px;
}
.message {
margin: 10px 0;
padding: 10px;
border-radius: 5px;
}
.user-message {
background-color: #eaeaea;
text-align: left;
}
.bot-message {
background-color: #d4ffc9;
text-align: right;
}
.user-message::before {
content: "You: ";
font-weight: bold;
}
.bot-message::before {
content: "Bot: ";
font-weight: bold;
}
input[type="text"] {
width: 100%;
padding: 10px;
border: none;
border-radius: 5px;
box-shadow: 0 0 5px rgba(0,0,0,0.2);
outline: none;
font-size: 16px;
}
</style>
</head>
<body>
<div class="container">
<div class="message user-message">
Hello, how can I help you?
</div>
<div class="message bot-message">
Hi there! I'm a chatbot. How can I assist you today?
</div>
<div class="message user-message">
I need help with my order.
</div>
<div class="message bot-message">
No problem, please provide your order number.
</div>
<div class="message user-message">
My order number is 12345.
</div>
<div class="message bot-message">
Got it. What is your question about the order?
</div>
<input type="text" placeholder="Type your message here...">
</div>
</body>
</html>
```
这个示例包含了一个基本的对话框界面,其中:
- `.container` 类定义了一个容器来包含所有的消息和输入框。
- `.message` 类定义了一个消息框,可以使用 `.user-message` 和 `.bot-message` 来区分用户和机器人的消息。
- `::before` 伪元素用来添加 "You: " 或 "Bot: " 的前缀。
- `input[type="text"]` 定义了一个输入框,用户可以在其中输入消息。
你可以根据需要进行修改和自定义样式。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)