Guest User

Untitled

a guest
Jan 22nd, 2018
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Slide Example</title>
  4. <style>
  5. .viewport {
  6. position: relative;
  7. overflow: hidden;
  8. width: 150px;
  9. height: 200px;
  10. border: 1px solid maroon;
  11. }
  12.  
  13. .box {
  14. position: absolute;
  15. width: 150px;
  16. height: 200px;
  17.  
  18. /* All just message formatting. */
  19. color: white;
  20. font-weight: bold;
  21. text-align: center;
  22. }
  23.  
  24. .box p {
  25. margin: 10px;
  26. margin-top: 50%;
  27. font-family: Tahoma;
  28. font-size: 15px;
  29. }
  30.  
  31. #green {
  32. top: 0px;
  33. background-color: darkgreen;
  34. }
  35.  
  36. #red {
  37. left: 150px;
  38. background-color: red;
  39. }
  40.  
  41. </style>
  42. <script type="text/javascript" src="jquery-1.6.2.min.js"></script>
  43. <script type="text/javascript">
  44.  
  45. var COUNTER = 1;
  46.  
  47. var StatusBox = {
  48. boxes: ['#green', '#red'],
  49. currentBox: 0,
  50. zIndex: 100,
  51. sliding: false,
  52. update: function (message) {
  53. if (!StatusBox.sliding) {
  54. StatusBox.sliding = true;
  55.  
  56. var currentBox = $(StatusBox.boxes[StatusBox.currentBox]);
  57. var boxIndex = StatusBox.currentBox ? 0 : 1;
  58. var box = $(StatusBox.boxes[boxIndex]);
  59. StatusBox.currentBox = boxIndex;
  60.  
  61. box.html("<p>" + message + "</p>");
  62. box.animate({left: 0}, 1500, function () {
  63. currentBox.hide().css({zIndex: StatusBox.zIndex++, left: 150}).show();
  64. StatusBox.sliding = false;
  65. });
  66. }
  67. }
  68. };
  69.  
  70. </script>
  71. </head>
  72. <body>
  73. <div class="viewport">
  74. <div class="box" id="green"><p></p></div>
  75. <div class="box" id="red"><p></p></div>
  76. </div>
  77. <p>
  78. <a href="#" onclick="StatusBox.update('Updated status of counter = ' + (COUNTER++)); return false;">Update Status</a>
  79. </p>
  80. </body>
  81. </html>
Add Comment
Please, Sign In to add comment