JSFiddle - React, Tailwind, and code Playground
by Evan Sharp
HTML
<div class="thing">
<hp-tooltip open="left">
<hp-icon font="question"></hp-icon>
<hp-tooltip-bubble ng-show="show">
<div class="hp-tooltip--content" ng-transclude>
This is the content<br />
This is the content<br />
This is the content<br />
This is the content<br />
</div>
</hp-tooltip-bubble>
</hp-tooltip>
<div>Other content here</div>
</div>
CSS
.thing {
padding: 100px;
}
hp-tooltip {
position: relative;
display: inline-block;
width: 16px;
}
hp-tooltip > hp-icon[font="question"] {
border-radius: 50%;
display: inline-block;
width: 16px;
height: 16px;
background-color: #0069E9;
color: #ffffff;
font-size: 14px;
letter-spacing: 1px;
line-height: 1.5;
text-align: center;
}
hp-tooltip > hp-icon[font="question"]::before {
display: block;
line-height: 1;
font-size: 14px;
}
hp-tooltip > hp-tooltip-bubble {
position: absolute;
z-index: 999;
margin: auto;
width: 175px;
padding: 15px 20px;
display: block;
border: 1px solid #0069E9;
background-color: #ffffff;
text-align: center;
}
hp-tooltip > hp-tooltip-bubble::before, hp-tooltip > hp-tooltip-bubble::after {
content: "";
position: absolute;
margin: auto;
width: 0;
height: 0;
border-style: solid;
}
hp-tooltip[open="up"] > hp-tooltip-bubble, hp-tooltip[open="down"] > hp-tooltip-bubble {
left: -100.5px;
}
hp-tooltip[open="up"] > hp-tooltip-bubble::before, hp-tooltip[open="up"] > hp-tooltip-bubble::after, hp-tooltip[open="down"] > hp-tooltip-bubble::before, hp-tooltip[open="down"] > hp-tooltip-bubble::after {
left: 0;
right: 0;
}
hp-tooltip[open="right"] > hp-tooltip-bubble, hp-tooltip[open="left"] > hp-tooltip-bubble {
top: 0;
bottom: 0;
}
hp-tooltip[open="right"] > hp-tooltip-bubble::before, hp-tooltip[open="right"] > hp-tooltip-bubble::after, hp-tooltip[open="left"] > hp-tooltip-bubble::before, hp-tooltip[open="left"] > hp-tooltip-bubble::after {
top: 0;
bottom: 0;
}
hp-tooltip[open="up"] > hp-tooltip-bubble {
bottom: 28px;
}
hp-tooltip[open="up"] > hp-tooltip-bubble::before {
bottom: -6px;
border-color: #0069E9 transparent transparent transparent;
border-width: 6px 9.5px 0 9.5px;
}
hp-tooltip[open="up"] > hp-tooltip-bubble::after {
bottom: -5px;
border-color: #ffffff transparent transparent transparent;
border-width: 5px 7.5px 0 7.5px;
}
hp-tooltip[open="right"] >...