Tooltip

by davidxmartins

HTML

<br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<div class="tooltip-wrapper">
  AVISO LEGAL
  <div class="tooltip">Get your text here</div>
</div>

CSS

.tooltip-wrapper {
  --tooltip-background: green;
  --tooltip-text-color: white;

  background: transparent;
  cursor: pointer;
  font-family: "Poppins", sans-serif;
  font-size: 12px;
  padding: 0;
  position: relative;
  line-height: 1;

}

.tooltip-wrapper .tooltip {
  background: var(--tooltip-background);
  color: var(--tooltip-text-color);
  display: block;
  position: absolute;
  width: auto;
  bottom: 100%;
  
  margin-bottom: 15px;
  opacity: 0;
  padding: 15px;
  pointer-events: none;
  transform: translateY(10px);
  transition: all 0.25s ease-out;
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
}

.tooltip-wrapper .tooltip:before {
  bottom: -20px;
  content: "";
  display: block;
  height: 20px;
  left: 0;
  position: absolute;
  width: 100%;
}

.tooltip-wrapper .tooltip:after {
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid var(--tooltip-background);
  bottom: -10px;
  content: "";
  height: 0;
  left: 50%;
  margin-left: -10px;
  position: absolute;
  width: 0;
}

.tooltip-wrapper:hover .tooltip {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0px);
}