HTML+CSS+JQuey模仿微信聊天app,能实现与所有人一起聊天
2024-12-26 14:22
以下是一个简单的仿微信聊天记录展示页面的HTML代码,使用了Vue.js和jQuery.scrollbar插件实现滚动条:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>仿微信聊天记录展示页面</title>
<link rel="stylesheet" href=https://blog.csdn.net/m0_62813523/article/details/"https://cdn.bootcdn.net/ajax/libs/jquery.scrollbar/0.2.11/jquery.scrollbar.min.css">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: #f2f2f2;
font-family: 'Helvetica Neue', sans-serif;
font-size: 14px;
}
.chat-box {
max-width: 600px;
margin: 20px auto;
background-color: #fff;
border-radius: 5px;
box-shadow: 0px 0px 5px #ccc;
overflow: hidden;
}
.chat-item {
display: flex;
align-items: flex-start;
padding: 10px;
border-bottom: 1px solid #eee;
}
.avatar {
width: 40px;
height: 40px;
margin-right: 10px;
border-radius: 50%;
overflow: hidden;
}
.avatar img {
width: 100%;
height: 100%;
object-fit: cover;
}
.content {
flex: 1;
}
.name {
font-weight: bold;
margin-bottom: 5px;
}
.message {
word-break: break-all;
margin-bottom: 5px;
}
.time {
color: #999;
font-size: 12px;
}
</style>
</head>
<body>
<div id="app">
<div class="chat-box">
<div class="chat-item" v-for="(item, index) in chatList" :key="index">
<div class="avatar">
<img :src=http://oml01z.riyuangf.com/static/image/nopic320.png alt="">
</div>
<div class="content">
<div class="name">{{ item.name }}</div>
<div class="message">{{ item.message }}</div>
<div class="time">{{ item.time }}</div>
</div>
</div>
</div>
</div>
<script src=https://blog.csdn.net/m0_62813523/article/details/"https://cdn.bootcdn.net/ajax/libs/vue/2.6.12/vue.min.js"></script>
<script src=https://blog.csdn.net/m0_62813523/article/details/"https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src=https://blog.csdn.net/m0_62813523/article/details/"https://cdn.bootcdn.net/ajax/libs/jquery.scrollbar/0.2.11/jquery.scrollbar.min.js"></script>
<script>
var app = new Vue({
el: '#app',
data: {
chatList: [
{
avatar: 'https://via.placeholder.com/50',
name: 'Alice',
message: 'Hello, how are you?',
time: '2021-09-01 10:00:00'
},
{
avatar: 'https://via.placeholder.com/50',
name: 'Bob',
message: 'I'm fine, thanks. And you?',
time: '2021-09-01 10:01:00'
},
{
avatar: 'https://via.placeholder.com/50',
name: 'Alice',
message: 'I'm good too.',
time: '2021-09-01 10:02:00'
},
{
avatar: 'https://via.placeholder.com/50',
name: 'Bob',
message: 'That's great.',
time: '2021-09-01 10:03:00'
}
]
},
mounted: function() {
// 初始化滚动条
$('.chat-box').scrollbar();
}
});
</script>
</body>
</html>
```