Advertisement
Guest User

snote example

a guest
Jul 3rd, 2014
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.16 KB | None | 0 0
  1. <!doctype html>
  2. <html lang="en">
  3. <title>snote example</title>
  4. <meta charset="utf-8">
  5.  
  6. <!-- Placed in the public domain by Roger Hågensen. -->
  7. <style>
  8. .snote
  9. {
  10.     width: 1em;
  11.     height: 1em;
  12.     background-image: url('http://icons.iconarchive.com/icons/visualpharm/must-have/256/Information-icon.png');
  13.     background-size: auto 1em;
  14.     background-repeat: no-repeat;
  15.     display: inline-block;
  16.     cursor: help
  17. }
  18.  
  19. .snote_tip
  20. {
  21.     display: block;
  22.     visibility: hidden;
  23.     position: absolute;
  24.     width: 16em;
  25.     height: 3em;
  26.     margin-left: -8em;
  27.     margin-top: -4em;
  28.     padding: 0.5em;
  29.     overflow: auto;
  30.     background: #cccccc;
  31.     color: #000000;
  32.     border: 0.15em solid #000000;
  33.     border-radius: 0.25em;  
  34.     box-shadow: 0.25em 0.25em 0.25em #7f7f7f;
  35. }
  36.  
  37. .snote:hover .snote_tip
  38. {
  39.     visibility: visible;
  40.     cursor: default;
  41. }
  42. </style>
  43.  
  44. <script>
  45.     //call this function once the page has loaded
  46.     window.addEventListener('load', snote_init, false);
  47.  
  48.     //this function will add a span with snote_tip class where a span with the snote class is used, this reduces the html needed and makes writing notes so much simpler/cleaner.
  49.     function snote_init()
  50.     {
  51.         var snote_elements = document.getElementsByClassName('snote');
  52.         for (var i = 0; i < snote_elements.length; i += 1)
  53.         {
  54.             var snote_element = snote_elements[i];
  55.             snote_element.innerHTML = '<span class="snote_tip">' + snote_element.innerHTML + '</span>';
  56.         }
  57.     }
  58. </script>
  59.  
  60. <body>
  61.  
  62. <br><br>
  63. <p>But the thing is this: I really, REALLY like annotations. I’m talking about the little numbers that pop up in a post <span class="snote">Like this one, for example.<br><br>And it is really long, but that is not really a problem.<br><br>This text could easily just go on and on.</span>. I ran into them on the <a href="http://what-if.xkcd.com/">XKCD What-If blog</a>.  They’re great for expanding on a side-thought without cluttering up the main body of the article. They’re handy when writing faux-technical articles that require lots of footnotes to save me from Death By Nitpick. They’re great for jokes <span class="snote">Since you can hide the <a href="http://en.wikipedia.org/wiki/Punch_line">punchline</a>.</span>. </p>
  64.  
  65. </body>
  66. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement