fixed.html 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-type" content="text/html; charset=utf-8">
  6. <title>fixed</title>
  7. <style type="text/css" media="screen">
  8. body { margin: 1px; padding: 5px; }
  9. div.fixed { position: fixed; margin: 1px; border: 2px solid #000; padding: 5px; width: 100px; height: 100px; background: #fff; overflow: hidden; }
  10. #fixed-1 { top: 0; left: 0; }
  11. #fixed-2 { top: 20px; left: 20px; }
  12. #forceScroll { width: 5000px; height: 5000px; }
  13. #marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
  14. </style>
  15. <script src="../../jquery.js"></script>
  16. <script type="text/javascript" charset="utf-8">
  17. jQuery(function($) {
  18. window.scrollTo(1000,1000);
  19. $('.fixed').click(function() {
  20. $('#marker').css( $(this).offset() );
  21. return false;
  22. });
  23. });
  24. </script>
  25. </head>
  26. <body>
  27. <div id="fixed-1" class="fixed"></div>
  28. <div id="fixed-2" class="fixed"></div>
  29. <div id="fixed-no-top-left" class="fixed"></div>
  30. <div id="forceScroll"></div>
  31. <div id="marker"></div>
  32. <p class="instructions">Click the white box to move the marker to it.</p>
  33. </body>
  34. </html>