JSFiddle - React, Tailwind, and code Playground
by BramVanroy
HTML
<ul id="readMoreUl">
<li>
<a href="#" target="_blank">First list item
<span class="tooltip">First tooltip</span>
</a>
</li>
<li>
<a href="#" target="_blank">Second list item
<span class="tooltip">Second tooltip</span>
</a>
</li>
<li>
<a href="#" target="_blank">Third list item
<span class="tooltip">
Third tooltip
</span>
</a>
</li>
</ul>
CSS
ul {
margin: 4em;
}
ul li {
display: list-item;
list-style: inside disc none;
font-size: 2em;
}
ul li a {
color: #ccc;
position: relative;
}
ul li a span.tooltip {
max-width: 360px;
width: auto;
height: auto;
font-size: 0.6em;
color: #fff;
position: absolute;
top: -50px;
left: 50px;
font-weight: bold;
text-decoration: none;
background-color: #2c8fd1;
padding: 0.5em 0.75em;
text-align: justify;
border-bottom: 4px solid #216c9e;
display: none;
line-height: 1.5;
font-weight: 100;
box-shadow: 0 5px 10px rgba(0,0,0,0.12), 0 0 20px rgba(0,0,0,0.2);
border-radius: 5px;
text-shadow: -1px -1px 0 rgba(0, 0, 0, 0.38);
}
ul li a:active span.tooltip {
border-bottom: 1px solid #216c9e;
top: -47px;
}
ul li a:hover span.tooltip {
z-index: 20;
}
JavaScript
function toolTip() {
var list = $("#readMoreUl");
var links = list.children("li").children("a");
var tooltips = links.children("span.tooltip");
var overlay = $("#overlay");
links.hover(function () {
$(this).addClass("highlight");
$(this).children("span.tooltip").fadeIn(350);
overlay.fadeIn(400);
},
function () {
$(this).children("span.tooltip").fadeOut(40);
overlay.fadeOut(30);
$(this).removeClass("highlight");
});
}
$(document).ready(function () {
$(window).resize(function() {
if ($(window).width() > 480) {
toolTip();
}
}).resize();
});