JSFiddle - React, Tailwind, and code Playground

Toggle tooltip

by Hugo Carneiro

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.css">
<div class="container">
<a class="tooltip" href="#"><i class="fa fa-circle-o animated pulse infinite"></i><span class="tooltip-content"><span class="tooltip-text"><span class="tooltip-inner">Howdy, Ben!<br /> There are 13 unread messages in your inbox.</span></span></span></a>
</div>

CSS

body {
  background-color: #a77dc2;
}

.container {
  padding-top: 50%;
  text-align: center;
}

.tooltip {
	display: inline;
	position: relative;
	z-index: 999;
  color: #ffeb3b;
}

/* Gap filler */
.tooltip::after {
	content: '';
	position: absolute;
	width: 100%;
	height: 20px;
	bottom: 100%;
	left: 50%;
	pointer-events: none;
	-webkit-transform: translateX(-50%);
	transform: translateX(-50%);
}

.tooltip:hover::after {
	pointer-events: auto;
}

/* Tooltip */

.tooltip-content {
	position: absolute;
	z-index: 9999;
	width: 300px;
	left: 50%;
	bottom: 100%;
	font-size: 20px;
	line-height: 1.4;
	text-align: center;
	font-weight: 400;
	color: #fffaf0;
	background: transparent;
	opacity: 0;
	margin: 0 0 20px -150px;
	cursor: default;
	pointer-events: none;
	-webkit-font-smoothing: antialiased;
	-webkit-transition: opacity 0.3s 0.3s;
	transition: opacity 0.3s 0.3s;
}

.tooltip.active .tooltip-content {
	opacity: 1;
	pointer-events: auto;
	-webkit-transition-delay: 0s;
	transition-delay: 0s;
}

.tooltip-content span {
	display: block;
}

.tooltip-text {
	border-bottom: 10px solid #00bcd4;
	overflow: hidden;
	-webkit-transform: scale3d(0,1,1);
	transform: scale3d(0,1,1);
	-webkit-transition: -webkit-transform 0.3s 0.3s;
	transition: transform 0.3s 0.3s;
}

.tooltip.active .tooltip-text {
	-webkit-transition-delay: 0s;
	transition-delay: 0s;
	-webkit-transform: scale3d(1,1,1);
	transform: scale3d(1,1,1);
}

.tooltip-inner {
	background: rgba(58, 58, 58, 0.8);
	padding: 40px;
	-webkit-transform: translate3d(0,100%,0);
	transform: translate3d(0,100%,0);
	webkit-transition: -webkit-transform 0.3s;
	transition: transform 0.3s;
}

.tooltip.active .tooltip-inner {
	-webkit-transition-delay: 0.3s;
	transition-delay: 0.3s;
	-webkit-transform: translate3d(0,0,0);
	transform: translate3d(0,0,0);
}

/* Arrow */

.tooltip-content::after {
	content: '';
	bottom: -20px;
	left: 50%;
	border: solid transparent;
	height: 0;
	width: 0;
	position: absolute;
	pointer-events:...

JavaScript

$('.tooltip').on('click', function() {
	$(this).toggleClass('active');
});