JSFiddle - React, Tailwind, and code Playground
by rami7250
HTML
<ul class="comment-section">
<li class="comment user-comment">
<div class="info">
<a href="#">Anie Silverston</a>
<span>4 hours ago</span>
</div>
<a class="avatar" href="#">
<img src="https://demo.tutorialzine.com/2015/11/using-flexbox-to-create-a-responsive-comment-section/images/avatar_user_1.jpg" width="35" alt="Profile Avatar" title="Anie Silverston">
</a>
<p>Suspendisse gravida sem?</p>
</li>
<li class="comment author-comment">
<div class="info">
<a href="#">Jack Smith</a>
<span>3 hours ago</span>
</div>
<a class="avatar" href="#">
<img src="https://demo.tutorialzine.com/2015/11/using-flexbox-to-create-a-responsive-comment-section/images/avatar_author.jpg" width="35" alt="Profile Avatar" title="Jack Smith">
</a>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse gravida sem sit amet molestie portitor.</p>
</li>
<li class="comment user-comment">
<div class="info">
<a href="#">Bradley Jones</a>
<span>1 hour ago</span>
</div>
<a class="avatar" href="#">
<img src="https://demo.tutorialzine.com/2015/11/using-flexbox-to-create-a-responsive-comment-section/images/avatar_user_2.jpg" width="35" alt="Profile Avatar" title="Bradley Jones">
</a>
<p>Suspendisse gravida sem sit amet molestie portitor?</p>
</li>
<li class="comment author-comment">
<div class="info">
<a href="#">Jack Smith</a>
<span>1 hour ago</span>
</div>
<a class="avatar" href="#">
<img...
CSS
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
html{
font: normal 13px sans-serif;
}
.comment-section{
list-style: none;
max-width: 800px;
width: 100%;
margin: 50px auto;
padding: 10px;
}
.comment{
display: flex;
border-radius: 3px;
margin-bottom: 45px;
flex-wrap: wrap;
}
.comment.user-comment{
color: #808080;
}
.comment.author-comment{
color: #60686d;
justify-content: flex-end;
}
/* User and time info */
.comment .info{
width: 17%;
}
.comment.user-comment .info{
text-align: right;
}
.comment.author-comment .info{
order: 3;
}
.comment .info a{ /* User name */
display: block;
text-decoration: none;
color: #656c71;
font-weight: bold;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
padding: 10px 0 3px 0;
}
.comment .info span{ /* Time */
font-size: 11px;
color: #9ca7af;
}
/* The user avatar */
.comment .avatar{
width: 8%;
}
.comment.user-comment .avatar{
padding: 10px 18px 0 3px;
}
.comment.author-comment .avatar{
order: 2;
padding: 10px 3px 0 18px;
}
.comment .avatar img{
display: block;
border-radius: 50%;
}
.comment.user-comment .avatar img{
float: right;
}
/* The comment text */
.comment p{
line-height: 1.5;
padding: 18px 22px;
width: 50%;
position: relative;
word-wrap: break-word;
}
.comment.user-comment p{
background-color: #f3f3f3;
}
.comment.author-comment p{
background-color: #e2f8ff;
order: 1;
}
.user-comment p:after{
content: '';
position: absolute;
width: 15px;
height: 15px;
border-radius: 50%;
background-color: #ffffff;
border: 2px solid #f3f3f3;
left: -8px;
top: 18px;
}
.author-comment p:after{
content: '';
position: absolute;
width: 15px;
height: 15px;
border-radius: 50%;
background-color: #ffffff;
border: 2px solid #e2f8ff;
right: -8px;
top:...