| 1 | <!doctype html> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | <meta charset="utf-8"> |
| 5 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 6 | <title>jQuery UI Tooltip - Custom Styling</title> |
| 7 | <link rel="stylesheet" href="../../themes/base/tooltip.css"> |
| 8 | <link rel="stylesheet" href="../demos.css"> |
| 9 | <script src="../../external/requirejs/require.js"></script> |
| 10 | <script src="../bootstrap.js"> |
| 11 | $( document ).tooltip({ |
| 12 | position: { |
| 13 | my: "center bottom-20", |
| 14 | at: "center top", |
| 15 | using: function( position, feedback ) { |
| 16 | $( this ).css( position ); |
| 17 | $( "<div>" ) |
| 18 | .addClass( "arrow" ) |
| 19 | .addClass( feedback.vertical ) |
| 20 | .addClass( feedback.horizontal ) |
| 21 | .appendTo( this ); |
| 22 | } |
| 23 | } |
| 24 | }); |
| 25 | </script> |
| 26 | <style> |
| 27 | .ui-tooltip, .arrow:after { |
| 28 | background: black; |
| 29 | border: 2px solid white; |
| 30 | } |
| 31 | .ui-tooltip { |
| 32 | padding: 10px 20px; |
| 33 | color: white; |
| 34 | border-radius: 20px; |
| 35 | font: bold 14px "Helvetica Neue", Sans-Serif; |
| 36 | text-transform: uppercase; |
| 37 | box-shadow: 0 0 7px black; |
| 38 | } |
| 39 | .arrow { |
| 40 | width: 70px; |
| 41 | height: 16px; |
| 42 | overflow: hidden; |
| 43 | position: absolute; |
| 44 | left: 50%; |
| 45 | margin-left: -35px; |
| 46 | bottom: -16px; |
| 47 | } |
| 48 | .arrow.top { |
| 49 | top: -16px; |
| 50 | bottom: auto; |
| 51 | } |
| 52 | .arrow.left { |
| 53 | left: 20%; |
| 54 | } |
| 55 | .arrow:after { |
| 56 | content: ""; |
| 57 | position: absolute; |
| 58 | left: 20px; |
| 59 | top: -20px; |
| 60 | width: 25px; |
| 61 | height: 25px; |
| 62 | box-shadow: 6px 5px 9px -9px black; |
| 63 | transform: rotate(45deg); |
| 64 | } |
| 65 | .arrow.top:after { |
| 66 | bottom: -20px; |
| 67 | top: auto; |
| 68 | } |
| 69 | </style> |
| 70 | </head> |
| 71 | <body> |
| 72 | |
| 73 | <p><a href="#" title="That's what this widget is">Tooltips</a> can be attached to any element. When you hover |
| 74 | the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip.</p> |
| 75 | <p>But as it's not a native tooltip, it can be styled. Any themes built with |
| 76 | <a href="https://jqueryui.com/themeroller/" title="ThemeRoller: jQuery UI's theme builder application">ThemeRoller</a> |
| 77 | will also style tooltips accordingly.</p> |
| 78 | <p>Tooltips are also useful for form elements, to show some additional information in the context of each field.</p> |
| 79 | <p><label for="age">Your age:</label> <input id="age" title="We ask for your age only for statistical purposes."></p> |
| 80 | <p>Hover the field to see the tooltip.</p> |
| 81 | |
| 82 | <div class="demo-description"> |
| 83 | <p>Hover the links above or use the tab key to cycle the focus on each element.</p> |
| 84 | </div> |
| 85 | </body> |
| 86 | </html> |