<div class="chat">
<div class="chat-message">
<p class="chat-text">This is my awesome test message. Be in awe of its verbose nature and thrilling content.</p>
</div>
<div class="chat-message">
<p class="chat-text">Be in awe of this message.</p>
</div>
<div class="chat-message">
<p class="chat-text">Do you even isolate, bro?</p>
</div>
<div class="chat-message me">
<p class="chat-text">I'm contributing to the conversation! How exciting is this! A chat feature WHILE we watch a study together!</p>
</div>
</div>
:root {
--black: #151515;
--gray100: #ddd;
--blue: #92D6E4;
--chat-tail-size: 21px;
}
body {
margin: 0;
height: 100vh;
background-color: var(--black);
display: grid;
place-items: center;
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
}
.chat {
display: grid;
grid-gap: 1rem;
justify-items: start;
padding: 1rem;
}
.chat-message {
--bubble-color: var(--gray100);
position: relative;
padding: .625rem;
background-color: var(--bubble-color);
border-radius: .625rem;
color: var(--bubble-color);
&.me {
--bubble-color: var(--blue);
justify-self: end;
.chat-text {
max-width: 28ch;
}
}
&::before,
&::after {
content: '';
position: absolute;
}
&::before {
height: calc(var(--chat-tail-size) * 1.2);
width: calc(var(--chat-tail-size) * .85);
background-color: currentColor;
border-radius: 50% 50% 20px/10px 0;
top: calc((100% - (var(--chat-tail-size) / 2)) - 11px);
right: calc((100% + (var(--chat-tail-size) / 2) * -1) + 4px);
left: auto;
}
&::after {
height: calc(var(--chat-tail-size) * 1.25);
width: var(--chat-tail-size);
background-color: var(--black);
border-radius: 0 0 16px/14px;
top: calc((100% - (var(--chat-tail-size) / 2)) - 11px);
right: 100%;
left: auto;
}
&.me {
&::before {
border-radius: 50% 50% 0 20px/10px;
left: calc((100% + (var(--chat-tail-size) / 2) * -1) + 3px);
right: auto;
}
&::after {
border-radius: 0 0 0 16px/14px;
left: 100%;
right: auto;
}
}
}
.chat-text {
margin: 0;
max-width: 32ch;
font-size: .875rem;
line-height: 1;
color: var(--black);
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.