JSFiddle - React, Tailwind, and code Playground

by gabrieleromanato

HTML

<div class="speech-bubble speech-bubble-top">Hi there</div>
<div class="speech-bubble speech-bubble-bottom">Hi there</div>
<div class="speech-bubble speech-bubble-left">Hi there</div>
<div class="speech-bubble speech-bubble-right">Hi there</div>

CSS

.speech-bubble {
  position: relative;
  background-color: #000;
 
  width: 200px;
  height: 150px;
  line-height: 150px; 
 
  color: white;
  text-align: center;
  border-radius: 10px;
 
  font-family: sans-serif;
    margin: 2em auto;
}
 
.speech-bubble:after {
  content: '';
  position: absolute;
 
  width: 0;
  height: 0;
 
  border: 15px solid;
}
 

 
.speech-bubble-top:after {
  border-bottom-color: #000;
 
  left: 50%;
  bottom: 100%;
  margin-left: -15px;
}
.speech-bubble-right:after {
  border-left-color: #000;
 
  left: 100%;
  top: 50%;
  margin-top: -15px;
}
 
.speech-bubble-bottom:after {
  border-top-color: #000;
 
  top: 100%;
  left: 50%;
  margin-left: -15px;
}
 
.speech-bubble-left:after {
  border-right-color: #000;
 
  top: 50%;
  right: 100%;
  margin-top: -15px;
}