Created
July 23, 2014 01:26
-
-
Save jimmyalcala/ab5911459697bcc35be6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body{ | |
margin:20px; | |
} | |
.tt{ | |
text-decoration:underline; | |
} | |
tooltip.active { | |
opacity: 1; | |
margin-top: 5px; | |
-webkit-transition: all 0.2s ease; | |
-moz-transition: all 0.2s ease; | |
-ms-transition: all 0.2s ease; | |
-o-transition: all 0.2s ease; | |
} | |
tooltip.out { | |
opacity: 0; | |
margin-top: -20px; | |
} | |
tooltip { | |
position: absolute; | |
background: #88b7d5; | |
border: 4px solid #c2e1f5; | |
} | |
tooltip:after, tooltip:before { | |
bottom: 100%; | |
left: 50%; | |
border: solid transparent; | |
content: " "; | |
height: 0; | |
width: 0; | |
position: absolute; | |
pointer-events: none; | |
} | |
tooltip:after { | |
border-color: rgba(136, 183, 213, 0); | |
border-bottom-color: #88b7d5; | |
border-width: 10px; | |
margin-left: -10px; | |
tooltip:before { | |
border-color: rgba(194, 225, 245, 0); | |
border-bottom-color: #c2e1f5; | |
border-width: 16px; | |
margin-left: -16px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="//code.jquery.com/jquery-2.1.0.min.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<br> | |
<br> | |
<div class='tt' title="Hi, Somebody here!"> | |
Hello World! | |
</div> | |
<br> | |
<div class='tt' title="Ok , I'm leaving!"> | |
Goodbye World! | |
</div> | |
<p>This is an awesome pararagraph with some <spam class='tt' title="Surprise i'm here!">helpful hints</spam > that you may</p> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.tt').mouseover(function(){ | |
var tt=this; | |
var p=$(tt).position(); | |
$(this).append( "<tooltip>"+this.title+"</tooltip>" ); | |
var h=$("tooltip").outerHeight(true); | |
var w=$("tooltip").outerWidth(); | |
$("tooltip").css({top:(p.top+22),left:p.left+45-(w/2)}); | |
}); | |
$('.tt').mouseout(function(){ | |
$("tooltip").remove(); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment