写一个html,模仿手机QQ聊天界面,要有昵称,头像,气泡
时间: 2024-03-23 12:35:53 浏览: 66
好的,以下是一个简单的示例,你可以根据需要进行修改和完善:
```html
<!DOCTYPE html>
<html>
<head>
<title>手机QQ聊天界面</title>
<meta charset="utf-8">
<style>
/* 设置页面背景色 */
body {
background-color: #f5f5f5;
}
/* 设置聊天气泡的样式 */
.bubble {
display: inline-block;
padding: 10px 15px;
border-radius: 10px;
max-width: 70%;
margin-bottom: 10px;
position: relative;
word-wrap: break-word;
font-size: 16px;
line-height: 1.5;
background-color: #fff;
}
/* 设置左边聊天气泡的样式 */
.bubble.left:before {
content: "";
display: inline-block;
position: absolute;
width: 0;
height: 0;
top: 10px;
left: -10px;
border-top: 10px solid transparent;
border-right: 10px solid #fff;
border-bottom: 10px solid transparent;
border-left: none;
}
/* 设置右边聊天气泡的样式 */
.bubble.right:before {
content: "";
display: inline-block;
position: absolute;
width: 0;
height: 0;
top: 10px;
right: -10px;
border-top: 10px solid transparent;
border-left: 10px solid #fff;
border-bottom: 10px solid transparent;
border-right: none;
}
/* 设置聊天框的样式 */
.chat-box {
width: 100%;
max-width: 600px;
margin: 20px auto;
padding: 20px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0,0,0,.1);
}
/* 设置聊天头像的样式 */
.avatar {
width: 50px;
height: 50px;
border-radius: 50%;
margin-right: 10px;
vertical-align: middle;
}
/* 设置昵称的样式 */
.nickname {
font-weight: bold;
font-size: 16px;
margin-bottom: 5px;
}
/* 设置时间的样式 */
.time {
font-size: 12px;
color: #999;
margin-left: 10px;
}
/* 设置左边聊天信息的样式 */
.left {
text-align: left;
}
/* 设置右边聊天信息的样式 */
.right {
text-align: right;
}
</style>
</head>
<body>
<div class="chat-box">
<div class="bubble left">
<div class="nickname">小明</div>
<img src="https://via.placeholder.com/50x50" class="avatar">
你好,我想问一下这个html怎么写?
<div class="time">09:00</div>
</div>
<div class="bubble right">
<div class="nickname">我</div>
<img src="https://via.placeholder.com/50x50" class="avatar">
你可以参考以下代码:
<pre>
<code>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>
</code>
</pre>
<div class="time">09:02</div>
</div>
<div class="bubble left">
<div class="nickname">小明</div>
<img src="https://via.placeholder.com/50x50" class="avatar">
好的,我试试,谢谢!
<div class="time">09:05</div>
</div>
</div>
</body>
</html>
```
注意:以上代码只是一个简单的示例,如果需要更加完善的聊天界面,需要根据实际需要进行修改和完善。
相关推荐
![](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)