tooltip with border

by Ting-Yuan Chang

HTML

<div class="tooltip">Hover over me
  <span class="tooltiptext">Tooltip text</span>
</div>

CSS

body {
  background: grey;
}
.tooltip {
    position: relative;
    display: inline-block;
    border-bottom: 1px dotted black;
    margin: 100px auto;
}

.tooltip .tooltiptext {
    /* visibility: hidden; */
    width: 120px;
    /* background-color: black; */
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px 0;
    position: absolute;
    z-index: 1;
    bottom: 150%;
    left: 50%;
    margin-left: -60px;
    border: 3px solid lightblue;
}

.tooltip .tooltiptext::before, .tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    border-style: solid;
}

.tooltip .tooltiptext::before {
    margin-left: -9px;
    border-width: 9px;
    border-color: lightblue transparent transparent transparent;
}

.tooltip .tooltiptext::after {
    margin-left: -5px;
    border-width: 5px;
    border-color: transparent transparent transparent transparent;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
}