mramine364

Simple Tooltip

Jan 16th, 2016
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 2.07 KB | None | 0 0
  1. <html>
  2. <head>
  3.     <meta charset="UTF-8">
  4.     <title>Tooltip - LuffyX</title>
  5. </head>
  6. <style>
  7.     .container{
  8.         text-align: center;
  9.         position: relative;
  10.     }
  11.     [data-toggle="tooltip"]{
  12.         text-decoration: none;
  13.         color: #2A90B9;
  14.         font-size: 16pt;
  15.     }
  16.     [data-toggle="tooltip"]:hover{
  17.         text-decoration: underline;
  18.         color: darkblue;
  19.     }
  20.     .tooltip_box{
  21.         position: absolute;
  22.         background: rgba(6, 5, 4, 0.06);
  23.         border: 3px solid #2005C7;
  24.         padding: 5px;
  25.         border-radius: 5px;
  26.         max-width: 340px;
  27.         direction: rtl;
  28.     }
  29.     .tooltip_box:after, .tooltip_box:before{
  30.         bottom: 100%;
  31.         left: 50%;
  32.         border: solid transparent;
  33.         content: " ";
  34.         height: 0;
  35.         width: 0;
  36.         position: absolute;
  37.         pointer-events: none;  
  38.        
  39.     }
  40.     .tooltip_box:after {
  41.         border-color: transparent;
  42.         border-bottom-color: rgb(240, 240, 240);
  43.         border-width: 9px;
  44.         margin-left: -9px;
  45.  
  46.     }
  47.     .tooltip_box:before {
  48.         border-color: transparent;
  49.         border-bottom-color: #2005c7;
  50.         border-width: 13px;
  51.         margin-left: -13px;
  52.     }
  53. </style>
  54. <body>
  55.  
  56.     <div class="container">
  57.         <a href="" data-toggle="tooltip" title="Tooltip: (تلميح) رسالة تظهر عندما يتم وضع المؤشر فوق رمز، صورة، الارتباط التشعبي أو عنصر آخر في واجهة المستخدم الرسومية.">
  58.             Tooltip - LuffyX.
  59.         </a>
  60.     </div>
  61.     <script>
  62.     var a = document.querySelector("[data-toggle=\"tooltip\"]");
  63.     var a_tooltip = document.createElement("div");
  64.     a_tooltip.className = "tooltip_box";
  65.     a_tooltip.setAttribute("role","Tooltip");
  66.     var a_title = document.createTextNode( a.title );
  67.     a.title = "";
  68.     a_tooltip.appendChild(a_title);
  69.  
  70.     a.addEventListener('mouseover',function(e){
  71.         a.parentNode.appendChild(a_tooltip);
  72.         a_tooltip.style.top = a.offsetTop+a.offsetHeight+10;
  73.         a_tooltip.style.left = a.offsetLeft-(a_tooltip.offsetWidth-a.offsetWidth)/2;
  74.     });
  75.     a.addEventListener('mouseout',function(){
  76.         if( a.nextElementSibling.getAttribute("role")=="Tooltip" ){
  77.             a.parentNode.removeChild(a.nextElementSibling)
  78.         }
  79.     });
  80.     </script>
  81.  
  82. </body>
  83. </html>
Advertisement
Add Comment
Please, Sign In to add comment