<h1>CSS speech bubble example</h1>
<div class="speech-bubble">
<p><strong>Demo speech bubble</strong></p>
<p>This is a simple CSS speech bubble.</p>
</div>
<div class="speech-bubble-ds">
<p><strong>Demo speech bubble</strong></p>
<p>This is CSS speech bubble with borders and drop shadow.</p>
<div class="speech-bubble-ds__arrow"></div>
</div>
<p style="text-align:center">Read more: <a href="https://auralinna.blog/post/2017/how-to-make-a-css-speech-bubble-with-borders-and-drop-shadow" target="_blank">How to make a CSS speech bubble with borders and drop shadow</a></p>
html, body {
color: #333;
font-size: 16px;
line-height: 20px;
}
body {
margin: 20px;
}
h1 {
line-height: 1.2;
margin-bottom: 35px;
text-align: center;
}
/** Speech bubble */
.speech-bubble {
background: #efefef;
border-radius: 4px;
font-size: 1.2rem;
line-height: 1.3;
margin: 0 auto 40px;
max-width: 400px;
padding: 15px;
position: relative;
p {
margin: 0 0 10px;
:last-of-type {
margin-bottom: 0;
}
}
&::after {
border-left: 20px solid transparent;
border-top: 20px solid #efefef;
bottom: -20px;
content: "";
position: absolute;
right: 20px;
}
}
/** Speech bubble with drop shadow and border */
.speech-bubble-ds {
background: #efefef;
border: 1px solid #a7a7a7;
border-radius: 4px;
box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.2);
font-size: 1.2rem;
line-height: 1.3;
margin: 0 auto 40px;
max-width: 400px;
padding: 15px;
position: relative;
p {
margin-bottom: 10px;
:last-of-type {
margin-bottom: 0;
}
}
}
.speech-bubble-ds__arrow {
border-left: 21px solid transparent;
border-top: 20px solid rgba(0, 0, 0, 0.2);
bottom: -25px;
position: absolute;
right: 15px;
&::before {
border-left: 23px solid transparent;
border-top: 23px solid #a7a7a7;
bottom: 2px;
content: "";
position: absolute;
right: 5px;
}
&::after {
border-left: 21px solid transparent;
border-top: 21px solid #efefef;
bottom: 4px;
content: "";
position: absolute;
right: 6px;
}
}
View Compiled
This Pen doesn't use any external JavaScript resources.