JSFiddle - React, Tailwind, and code Playground
by secretgspot
HTML
<section id="main">
<article>
<h1 id="positionText">Help Tips</h1>
<div>
This is a tooltip attached to a link.
<a class="button menu" href="#" title="RUSO">Element 1</a>
<span class="helptip" rel="tip_1" data-title="Element 1 Title">?</span>
</div>
<div>
This is a tooltip attached to a link.
<a class="button menu" href="#" title="KUZYA">Label 2</a>
<span class="helptip" rel="tip_2" data-title="Element 2 Title">!</span>
</div>
<div>
This is a tooltip attached to a link.
<a class="button menu" href="#">Some Element 3</a>
<span class="helptip" rel="tip_3" data-title="Element 3 Title">@</span>
</div>
</article>
</section>
<div id="helptip_wrap">
<label id="helptip_title">Title goes here</label>
<div id="helptip_content">Either video or text goes here (HTML supported)</div>
</div>
CSS
span[rel]:hover {
position: relative;
}
span[rel]:hover:after {
content: attr(rel);
padding: 3px;
position: absolute;
right: 100%;
top: 100%;
white-space: nowrap;
z-index: 999;
-moz-box-shadow: 0px 0px 4px #222;
-webkit-box-shadow: 0px 0px 4px #222;
box-shadow: 0px 0px 4px #222;
background: #fff;
}
span.helptip {
display: inline-block;
width: 14px;
height: 14px;
border: 1px solid #febf04;
border-radius: 14px;
vertical-align: middle;
text-align: center;
font-size: 12px;
line-height: 14px;
cursor: pointer;
color: #38c;
font-weight: bold;
margin-left: 13px;
background: rgb(255,255,136);
background: -moz-linear-gradient(top, rgb(255,255,136) 0%, rgb(255,255,136) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgb(255,255,136)), color-stop(100%,rgb(255,255,136)));
background: -webkit-linear-gradient(top, rgb(255,255,136) 0%,rgb(255,255,136) 100%);
background: -o-linear-gradient(top, rgb(255,255,136) 0%,rgb(255,255,136) 100%);
background: -ms-linear-gradient(top, rgb(255,255,136) 0%,rgb(255,255,136) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffff88', endColorstr='#ffff88',GradientType=0 );
background: linear-gradient(top, rgb(255,255,136) 0%,rgb(255,255,136) 100%);
}
#helptip_wrap {
display: block;
position: absolute;
border: 1px solid rgb(250,250,250);
margin: 3px;
padding: 3px;
font-size: 13px;
background-color: rgb(250,250,250); /* Needed for IEs */
-moz-box-shadow: 3px 3px 6px rgba(32,32,32,0.3);
-webkit-box-shadow: 3px 3px 6px rgba(32,32,32,0.3);
box-shadow: 3px 3px 6px rgba(32,32,32,0.3);
filter: progid:DXImageTransform.Microsoft.Blur(PixelRadius=3,MakeShadow=true,ShadowOpacity=0.30);
-ms-filter: "progid:DXImageTransform.Microsoft.Blur(PixelRadius=3,MakeShadow=true,ShadowOpacity=0.30)";
zoom: 1;
}
#helptip_wrap #helptip_title {
...
JavaScript
$('span[rel]').click(function(){
//alert($(this).attr('rel'));
var $this = $(this);
var position = $this.offset();
var helptip_wrap = $("#helptip_wrap");
var helptip_title = $("#helptip_title");
var helptip_content = $("#helptip_content");
helptip_title.text($this.attr("data-title"));
helptip_wrap.insertAfter($this);
helptip_wrap.css(position);
});