又有两个月没更新了,主要是自己懒。

博友们对我的邮件通知模板感兴趣,与其辛苦Copy,还不如我直接分享出来,还能顺便水一篇日志。最早不记得是看到谁的模板,也是这种聊天的形式,于是想着就仿一个大家熟悉的微信界面,废话不多说。

效果图

在线演示:码上掘金 | CodePen

HTML

<div id="comment2u">
  <div class="wrap">
    <div class="header">嘀咕 digu.plus (2)</div>
    <div class="body">
      <div class="item notice">
        "大佬"发布了《<a href="#">仿微信PC界面</a>》,访客可通过评论加入
      </div>
      <div class="item notice">"大佬"发起了群聊,访客可通过评论加入</div>
      <div class="item notice">"大佬"通过评论加入了群聊</div>
      <div class="item notice">2016-03-18 02:18:00</div>
      <div class="item parent">
        <div class="scope">
          <div class="nick">评论者</div>
          <div class="content">
            <span class="arrow"></span>
            <p>人生最好的三种状态:不期而遇、不言而喻、不药而愈。</p>
          </div>
        </div>
        <div class="avatar">
          <img src="https://cravatar.cn/avatar?d=monsterid&s=40" alt="" />
        </div>
      </div>
      <div class="item notice">2019-09-17 01:23:00</div>
      <div class="item child">
        <div class="avatar">
          <img src="https://cravatar.cn/avatar?d=monsterid&s=40" alt="" />
        </div>
        <div class="scope">
          <div class="nick">回复者</div>
          <div class="content">
            <span class="arrow"></span>
            <p>人生最好的三个词:久别重逢,失而复得,虚惊一场。</p>
          </div>
        </div>
      </div>
      <div class="item notice">
        你被"大佬"移出群聊,请在
        "<a target="_blank" href="https://digu.plus">这里</a>"
        进行投诉
      </div>
    </div>
  </div>
</div>

CSS

#comment2u {
  font-size: 14px;
  margin: 0 auto;
  width: 720px;
  max-width: 100%;
  background-color: #eee;
  border-radius: 3px;
  -moz-border-radius: 3px;
  -webkit-border-radius: 3px;
}
#comment2u .wrap {
  padding: 10px 20px;
}
#comment2u .header {
  line-height: 30px;
  position: relative;
  padding-bottom: 10px;
  border-bottom: 1px solid #d6d6d6;
  background-color: #eee;
  text-align: center;
  margin-bottom: 12px;
}
#comment2u .body {
  min-height: 600px;
}

#comment2u .notice {
  max-width: 50%;
  text-align: center;
  font-size: 12px;
  margin: 0 auto;
  padding: 1px 18px;
  color: #b2b2b2;
  line-height: 24px;
}
#comment2u .notice a {
  color: #526685;
  text-decoration: none;
}
#comment2u .item {
  display: flex;
  margin-bottom: 12px;
}
#comment2u .notice {
  justify-content: center;
}
#comment2u .parent {
  justify-content: flex-end;
}
#comment2u .child {
  justify-content: flex-start;
}
#comment2u .parent .content {
  background-color: #b2e281;
}
#comment2u .child .content {
  background-color: #ffffff;
}
#comment2u .item .avatar img {
  width: 40px;
  height: 40px;
  border-radius: 2px;
  -moz-border-radius: 2px;
  -webkit-border-radius: 2px;
  cursor: pointer;
}
#comment2u .child .nick {
  padding-left: 10px;
  font-size: 12px;
  height: 24px;
  color: #4f4f4f;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-wrap: normal;
}
#comment2u .parent .nick {
  text-align: right;
  padding-right: 10px;
  font-size: 12px;
  height: 24px;
  color: #4f4f4f;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-wrap: normal;
}
#comment2u .item .content {
  word-wrap: break-word;
  word-break: break-all;
  min-height: 25px;
  max-width: 500px;
  min-height: 1em;
  font-size: 14px;
  border-radius: 3px;
  -moz-border-radius: 3px;
  -webkit-border-radius: 3px;
  margin: 0 10px;
  text-align: left;
  position: relative;
  padding: 10px 15px;
}
#comment2u .parent .arrow {
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 6px solid;
  border-left-color: #b2e281;
  border-right: 0;
  border-right-color: transparent;
  right: -6px;
  left: auto;
  top: 12px;
  position: absolute;
}
#comment2u .child .arrow {
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 6px solid;
  border-right-color: #ffffff;
  border-left: 0;
  border-left-color: transparent;
  right: auto;
  left: -6px;
  top: 12px;
  position: absolute;
}
#comment2u .item .content p {
  margin: 0;
  line-height: 1.6;
}