html - 如何在消息聊天框中显示姓名、当前时间

标签 html css chat

我们开发的聊天应用程序看起来像 watts-app。我们完成了一切,但我想在聊天消息框中显示姓名和当前时间。怎么做

requirement screen shot

enter image description here

.left {
  position: relative;
  background: white;
  text-align: right;
  padding: 10px 15px;
  border-radius: 6px;
  border: 1px solid #ccc;
  float: right;
  right: 20px;
}

.left::before {
  content: '';
  position: absolute;
  visibility: visible;
  top: -1px;
  right: -10px;
  border: 10px solid transparent;
  border-top: 10px solid #ccc;
}

.left::after {
  content: '';
  position: absolute;
  visibility: visible;
  top: 0px;
  right: -8px;
  border: 10px solid transparent;
  border-top: 10px solid white;
  clear: both;

}

div{
  clear: right;
}
<div class="left">
  <p style="margin-top: 0px;margin-bottom: 0px;color:green;font-size: 11px;">Kranti</p>
  <span>thanks</span>
   <p style="float: left;margin-bottom: 0px;color:red;font-size: 11px;">2:33 PM</p>
</div>

最佳答案

您可以使用自己的类创建多个 span 元素,并将用户名和时间样式设置为它们的位置。

使用绝对定位将样式设置为您提供的图像。

给你:https://jsfiddle.net/keqh0cqw/1/

您的新 html 示例:

<div class="right">
    <span class="username">kranthi</span>
    <span class="message">thanks</span>
    <span class="time">12:08</span>
</div>

关于html - 如何在消息聊天框中显示姓名、当前时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36908724/

相关文章:

html - CSS 列数和 Chrome 错误 : how to avoid overflow content being cropped

php - 有没有办法将 vBulletin 集成到 PHP 中?

php - 如何使用 PHP 在我的网站上提供即时聊天功能?

html - 如何在页脚上设置背景图像

css - 我可以使用什么 CSS 来缩放 Canvas 以填充其容器而不改变其纵横比?

Java聊天服务器

Android DatagramSocket错误信息: EADDRINUSE (Address already in use)

html - 两个按钮和文本具有不同的对齐方式

css - 为什么包装 DIV 的多样性?

php - 自动创建php页面