I am trying to make a facebook style chat bubble using sibling selector. I have tryed this DEMO But the siblings doesn't worked like this DEMO . The second demo answer from stackoverflow user by Serg Chernata .
What i am missing anyone can help me please ? Or is there anyway to do it like facebook chat bubble ?
*{
box-sizing:border-box;
position:relative;
}
.container {
width:100%;
max-width:400px;
margin:0px auto;
padding:15px;
background-color:#fafafa;
border-radius:3px;
margin-top:50px;
border:1px solid #f5f5f5;
font-family: Arial,"Helvetica Neue",Helvetica,sans-serif;
}
.conversations {
display:inline-block;
width:100%;
padding:50px 0px;
}
.box {
width:100%;
padding:1px 0px;
display:inline-block;
font-size:14px;
font-weight:400;
}
.you {
max-width:60%;
border-radius:30px;
background-color:#d8dbdf;
padding:15px;
float:left;
}
.me {
max-width:60%;
border-radius:30px;
background-color:#0084ff;
padding:15px;
float:right;
color:#ffffff;
font-weight:300;
}
.box .you + .me{
border-bottom-right-radius: 5px;
}
.box .me + .me{
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
}
.box .me:last-of-type {
border-bottom-right-radius: 30px;
}
<div class="container">
<div class="conversations">
<div class="box"><div class="you">1 Message</div></div>
<div class="box"><div class="me">2 Message</div></div>
<div class="box"><div class="me">3 Message</div></div>
<div class="box"><div class="you">4 Message</div></div>
<div class="box"><div class="you">5 Message</div></div>
<div class="box"><div class="me">6 Message</div></div>
<div class="box"><div class="me">6 Message</div></div>
</div>
</div>