Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!

Untitled

By: userdude on Dec 28th, 2012  |  syntax: JavaScript  |  size: 2.42 KB  |  views: 229  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. <html><head>
  3.   <meta content="text/html; charset=UTF-8" http-equiv="content-type">
  4.   <title> - jsFiddle demo</title>
  5.  
  6.   <script type='text/javascript' src='http://www.altesc.net/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script>
  7.  
  8.  
  9.   <style type="text/css">
  10.     .body { float: left; width: 200px; padding: 5px; }
  11. .sidebar { float: left; }
  12. .item { margin: 10px; width: 100px; height: 100px; background-color: black; }
  13. .unimportant { background-color: #ccc; height: 300px;}
  14. .adscrollleft { background-color: #ccc;}
  15. .fixedSidebar { position: fixed; top: 0; }
  16.   </style>
  17. <script type="text/javascript">//<![CDATA[
  18.  
  19. jQuery(window).load(function(){
  20.     jQuery(document).scroll(function() {
  21.         var useFixedSidebar = jQuery(document).scrollTop() > 330;
  22.         jQuery('.adscrollleft').toggleClass('fixedSidebar', useFixedSidebar);
  23.     });
  24. });
  25.  
  26. //]]></script>
  27. </head>
  28. <body>
  29.   <div class="body">
  30.     document body.<br>
  31.     document body..<br>
  32.     document body...<br>
  33.     document body....<br>
  34.     document body.....<br>
  35.     document body......<br>
  36.     document body.....<br>
  37.     document body....<br>
  38.     document body...<br>
  39.     document body..<br>
  40.     document body.<br>
  41.     document body..<br>
  42.     document body...<br>
  43.     document body....<br>
  44.     document body.....<br>
  45.     document body......<br>
  46.     document body.....<br>
  47.     document body....<br>
  48.     document body...<br>
  49.     document body..<br>
  50.     document body.<br>
  51.     document body..<br>
  52.     document body...<br>
  53.     document body....<br>
  54.     document body.....<br>
  55.     document body......<br>
  56.     document body.....<br>
  57.     document body....<br>
  58.     document body...<br>
  59.     document body..<br>
  60.     document body.<br>
  61.     document body..<br>
  62.     document body...<br>
  63.     document body....<br>
  64.     document body.....<br>
  65.     document body......<br>
  66.     document body.....<br>
  67.     document body....<br>
  68.     document body...<br>
  69.     document body..<br>
  70.     document body.<br>
  71.     document body..<br>
  72.     document body...<br>
  73.     document body....<br>
  74.     document body.....<br>
  75.     document body......<br>
  76.     document body.....<br>
  77.     document body....<br>
  78.     document body...<br>
  79.     document body..<br>
  80.     document body.<br>
  81. </div>
  82. <div class="sidebar">
  83.  
  84.     <div class="adscrollleft">
  85.         <div class="item"></div>
  86.         <div class="item"></div>
  87.     </div>
  88. </div>
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95. </body></html>