JSFiddle - React, Tailwind, and code Playground
by Diego Vieira
HTML
<ol class="discussion">
<li class="other">
<div class="avatar">
<img src="http://s3-us-west-2.amazonaws.com/s.cdpn.io/5/profile/profile-80_9.jpg" />
</div>
<div class="messages">
<p>yeah, they do early flights cause they connect with big airports. they wanna get u to your connection</p>
<time datetime="2009-11-13T20:00">Timothy • 51 min</time>
</div>
</li>
<li class="self">
<div class="avatar">
<img src="http://cdn.screenrant.com/wp-content/uploads/Rocket-Raccoon-in-Guardians-of-the-Galaxy-international-trailer.jpg" />
</div>
<div class="messages">
<p>That makes sense.</p>
<p>It's a pretty small airport.</p>
<time datetime="2009-11-13T20:14">37 mins</time>
</div>
</li>
<li class="other">
<div class="avatar">
<img src="http://s3-us-west-2.amazonaws.com/s.cdpn.io/5/profile/profile-80_9.jpg" />
</div>
<div class="messages">
<p>that mongodb thing looks good, huh?</p>
<p>
tiny master db, and huge document store</p>
</div>
</li>
</ol>
CSS
.discussion {
list-style: none;
background: #e5e5e5;
margin: 0;
padding: 0 0 50px 0;
}
.discussion li {
padding: 0.5rem;
overflow: hidden;
display: flex;
}
.discussion .avatar {
width: 40px;
position: relative;
}
.discussion .avatar img {
display: block;
width: 100%;
}
.other .avatar:after {
content: "";
position: absolute;
top: 0;
right: 0;
width: 0;
height: 0;
border: 5px solid white;
border-left-color: transparent;
border-bottom-color: transparent;
}
.self {
justify-content: flex-end;
align-items: flex-end;
}
.self .messages {
order: 1;
border-bottom-right-radius: 0;
}
.self .avatar {
order: 2;
width:40px;
height:40px;
}
.self .avatar img {
}
.self .avatar:after {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 0;
height: 0;
border: 5px solid white;
border-right-color: transparent;
border-top-color: transparent;
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}
.messages {
background: white;
padding: 10px;
border-radius: 2px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.messages p {
font-size: 0.8rem;
margin: 0 0 0.2rem 0;
}
.messages time {
font-size: 0.7rem;
color: #ccc;
}