JSFiddle - React, Tailwind, and code Playground
by Evan Sharp
HTML
<div class="thing">
<hp-tooltip open="up">
<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>
<hp-tooltip open="right">
<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>
<hp-tooltip open="down">
<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>
<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;
height: 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;
cursor: pointer;
}
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;
border: 1px solid #0069E9;
background-color: #ffffff;
text-align: center;
display:table;
pointer-events: none;
opacity: 0;
-webkit-transition: all .25s ease-out;
-moz-transition: all .25s ease-out;
-ms-transition: all .25s ease-out;
-o-transition: all .25s ease-out;
transition: all .25s ease-out;
-webkit-transition-delay: 0.5s;
-moz-transition-delay: 0.5s;
-ms-transition-delay: 0.5s;
-o-transition-delay: 0.5s;
transition-delay: 0.5s;
}
hp-tooltip:hover > hp-tooltip-bubble{
opacity: 1;
pointer-events: auto;
}
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"] >...