# S4: 微信风格消息气泡布局 ## 目标 修改 `chat.html` 的消息渲染,实现微信风格布局: - 他人消息:左对齐(头像 + 昵称 + 气泡 + 时间) - 自己消息:右对齐(气泡 + 时间) - 气泡色:他人白 #FFF,自己绿 #95EC69(已有) - 头像:CSS 字母占位符(首字母+背景色),无头像时默认占位 ## 涉及文件 - `templates/chat.html`:CSS + renderMsg() 函数 ## 当前布局 ```
内容
时间
``` ## 新布局 Received: ```
首字母
昵称
内容
时间
``` Sent: ```
内容
时间
``` ## CSS 新增 - .msg-row: flex 容器 - .msg-row.received: justify-content:flex-start - .msg-row.sent: justify-content:flex-end - .msg-avatar: 36px 圆形,背景色根据用户名 hash - .msg-nickname: 小字灰色 - .msg-content: 限制 max-width ## 验证 - curl 聊天页 → 检查 .msg-avatar, .msg-nickname, .msg-row 存在 - smoketest 8/8