<h1>Speech Bubbles in CSS only</h1>
<a class="photo-wrap" href="#"><img class="photo" src="https://picsum.photos/175/175" alt="Picture of Me">
<div class="speechbox">
<p>SitePoint Rocks!</p>
</div>
</a>
<a class="photo-wrap" href="#"><img class="photo" src="https://picsum.photos/185/185" alt="Picture">
<div class="speechbox">
<p>SitePoint Rocks! <br>Lorem Ipsum dolor sit amet</p>
</div>
</a>
<a class="photo-wrap" href="#"><img class="photo" src="https://picsum.photos/195/195" alt="Picture">
<div class="speechbox">
<p>SitePoint Rocks! <br>Lorem Ipsum dolor sit amet Lorem Ipsum dolor sit amet Lorem Ipsum dolor sit amet Lorem Ipsum dolor sit amet</p>
</div>
</a>
<a class="photo-wrap bubble-large" href="#"><img class="photo" src="https://picsum.photos/175/175" alt="Picture">
<div class="speechbox">
<p>SitePoint Rocks! <br>Lorem Ipsum dolor sit amet Lorem Ipsum dolor sit amet Lorem Ipsum dolor sit amet Lorem Ipsum dolor sit amet</p>
</div>
</a>
<a class="photo-wrap bubble-percent" href="#"><img class="photo" src="https://picsum.photos/175/175" alt="Picture">
<div class="speechbox">
<p>SitePoint Rocks! <br>Lorem Ipsum dolor sit amet Lorem Ipsum dolor sit amet Lorem Ipsum dolor sit amet Lorem Ipsum dolor sit amet</p>
</div>
</a>
body {
background: #335577;
}
.photo-wrap {
display: inline-flex;
position: relative;
margin: 100px 25px;
border-radius: 50%;
z-index:1;
}
.photo-wrap img {
border-radius: 50%;
max-width: 175px;
height: auto;
z-index:-2;
}
.speechbox {
position: absolute;
right: 999rem;
bottom: 100%;
width: 200px;
min-width:135px;
height: auto;
text-align: center;
background:#fff;
border: 4px solid #000;
border-radius: 30px;
opacity: 0;
transition: opacity 1s ease, right 0s 1s;
filter: drop-shadow(4px 4px 4px rgba(255,255,255,0.6));
}
.bubble-large .speechbox{width:400px;}
.bubble-percent .speechbox{width:40vw;}
.speechbox:before,
.speechbox:after,
.speechbox p:after {
content: "";
bottom: -32px;
right: 70px;
position: absolute;
display: block;
width: 38px;
height: 26px;
border-radius: 0 0 18px 38px;
box-shadow: 14px 14px 0px 11px #fff;
transform: rotate(-90deg);
z-index: -1;
}
.speechbox:before {
box-shadow: 14px 14px 0px 14px black;
z-index: -1;
right: 73px;
}
.speechbox:after {
box-shadow: 14px 14px 0px 14px black;
z-index: -1;
}
.speechbox p {
display: flex;
justify-content: center;
align-items: center;
color: red;
z-index: 3;
margin: 0;
position: relative;
min-height: 60px;
padding: 10px;
background-color:#fff;/* hide spike during transition*/
border-radius:34px;
}
/* hover styles */
.photo-wrap:hover .speechbox {
right: -50px;
opacity: 1;
transition: opacity 1s ease, right 0s;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.