bootstrap聊天模板
时间: 2024-12-30 17:14:20 浏览: 5
### Bootstrap 聊天界面模板
为了创建一个基于Bootstrap的聊天界面,可以利用其栅格系统、组件以及实用工具类来构建响应式的布局。下面是一个简单的聊天界面示例代码:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Chat Interface</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"/>
<style>
.chat-container {
height: 400px;
overflow-y: scroll;
}
.message-bubble {
margin-bottom: 1em;
padding: 10px;
border-radius: 10px;
}
.sent-message {
background-color: #e9f7ef;
float: left;
clear: both;
}
.received-message {
background-color: #fff3cd;
float: right;
clear: both;
}
</style>
</head>
<body>
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-6 chat-container">
<!-- Sent Message -->
<div class="media sent-message message-bubble">
<img src="https://via.placeholder.com/50" alt="" class="mr-3 rounded-circle align-self-start">
<div class="media-body">
Hello, how are you?
</div>
</div>
<!-- Received Message -->
<div class="media received-message message-bubble">
<div class="media-body text-right">
I'm good! How about you?
</div>
<img src="https://via.placeholder.com/50" alt="" class="ml-3 rounded-circle align-self-end">
</div>
</div>
<!-- Input Area -->
<div class="input-group mb-3 col-md-6 offset-md-3">
<textarea class="form-control" aria-label="With textarea"></textarea>
<div class="input-group-append">
<button type="submit" class="btn btn-primary">Send</button>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.2/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>
```
此HTML文档定义了一个基本结构用于展示消息列表和输入框[^1]。
阅读全文