CSS 툴팁

by JM note

HTML

<style>
.tooltip {
  cursor: pointer;
}
.tooltip .tooltiptext {
  display: none;
  background: #000;
  color: #fff;
  width: 120px;
  border-radius: 5px;
  padding: 5px;
  font-size: 14px;
  text-align: center;
  position: absolute;
  z-index: 9;
}
.tooltip:hover .tooltiptext {
  display: inline;
}
</style>

<button class="tooltip">Button1
  <span class="tooltiptext">Hello, World!</span>
</button>
<hr>
<button class="tooltip">Button2
  <span class="tooltiptext">Hi, there!<br>Are you my mother?</span>
</button>