如何将弯曲的箭头放在对话泡泡的顶部?

How to place curved arrow on top of your speech bubble?

我想使用 css.

创建类似于下图的对话框

我该怎么做?

您可以使用带有透明圆圈的 radial-gradient 来创建对话泡泡的弯曲尖端。将其应用于气泡的 ::before 伪元素,使其位于对话气泡 div.

的顶部

.bubble::before {
  content: '';
  height: 30px;
  width: 30px;
  background: radial-gradient(circle at 100% 0, transparent 30px, cornflowerblue 0);
  display: block;
  margin-left: 100px;
}

.message {
  padding: 10px 20px;
  width: 300px;
  background: cornflowerblue;
  display: block;
  font-family: sans-serif;
  color: floralwhite;
  font-size: 18px;
  border-radius: 0 0 10px 10px;
}
<div class="bubble">
  <div class="message">
     <p>"Tell me and I forget. Teach me and I remember. Involve me and I learn."<p>
     <small>Benjamin Franklin</small>
  </div>
</div>

悬停时添加边框

您可以将 ::after 伪元素与 z-index 结合使用,在将鼠标悬停在对话气泡上时创建边框效果。

.bubble::before,
.bubble::after {
  content: '';
  display: block;
  position: absolute;
}

.bubble::before {
  background: radial-gradient(circle at 95% -2px, transparent 25px, cornflowerblue 0);
  left: 103px;
  top: 10px;
  z-index: 1;
  height: 25px;
  width: 25px;
}

.bubble::after {
  background: radial-gradient(circle at 100% 0, transparent 30px, coral 0);
  left: 100px;
  top: 0px;
  z-index: -1;
  height: 30px;
  width: 30px;
  display: none;
}

.message {
  padding: 10px 20px;
  width: 300px;
  background: cornflowerblue;
  display: block;
  font-family: sans-serif;
  color: floralwhite;
  font-size: 18px;
  border-radius: 0 0 10px 10px;
  border: 3px solid white;
  margin-top: 30px;
}

.bubble:hover > .message {
  border: 3px solid coral;
}

.bubble:hover::after {
  display: block;
}
<div class="bubble">
  <div class="message">
     <p>"Tell me and I forget. Teach me and I remember. Involve me and I learn."<p>
     <small>Benjamin Franklin</small>
  </div>
</div>