Guest User

load more content

a guest
May 26th, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. <html>
  2. <head>
  3. <style>
  4. body {
  5. background-color: #f6f6f6;
  6. width: 400px;
  7. margin: 20px auto;
  8. font: normal 13px/100% sans-serif;
  9. color: #444;
  10. }
  11. div {
  12. display:none;
  13. padding: 10px;
  14. border-width: 0 1px 1px 0;
  15. border-style: solid;
  16. border-color: #fff;
  17. box-shadow: 0 1px 1px #ccc;
  18. margin-bottom: 5px;
  19. background-color: #f1f1f1;
  20. }
  21. .totop {
  22. position: fixed;
  23. bottom: 10px;
  24. right: 20px;
  25. }
  26. .totop a {
  27. display: none;
  28. }
  29. a, a:visited {
  30. color: #33739E;
  31. text-decoration: none;
  32. display: block;
  33. margin: 10px 0;
  34. }
  35. a:hover {
  36. text-decoration: none;
  37. }
  38. #loadMore {
  39. padding: 10px;
  40. text-align: center;
  41. background-color: #33739E;
  42. color: #fff;
  43. border-width: 0 1px 1px 0;
  44. border-style: solid;
  45. border-color: #fff;
  46. box-shadow: 0 1px 1px #ccc;
  47. transition: all 600ms ease-in-out;
  48. -webkit-transition: all 600ms ease-in-out;
  49. -moz-transition: all 600ms ease-in-out;
  50. -o-transition: all 600ms ease-in-out;
  51. }
  52. #loadMore:hover {
  53. background-color: #fff;
  54. color: #33739E;
  55. }
  56. </style>
  57. <script type="text/javascript">
  58. $(function () {
  59. $("div").slice(0, 6).show();
  60. $("#loadMore").on('click', function (e) {
  61. e.preventDefault();
  62. $("div:hidden").slice(0, 4).slideDown();
  63. if ($("div:hidden").length == 0) {
  64. $("#load").fadeOut('slow');
  65. }
  66. $('html,body').animate({
  67. scrollTop: $(this).offset().top
  68. }, 1500);
  69. });
  70. });
  71.  
  72. $('a[href=#top]').click(function () {
  73. $('body,html').animate({
  74. scrollTop: 0
  75. }, 600);
  76. return false;
  77. });
  78.  
  79. $(window).scroll(function () {
  80. if ($(this).scrollTop() > 50) {
  81. $('.totop a').fadeIn();
  82. } else {
  83. $('.totop a').fadeOut();
  84. }
  85. });
  86. </script>
  87. </head>
  88. <body>
  89. <div>Content</div>
  90. <div>Content</div>
  91. <div>Content</div>
  92. <div>Content</div>
  93.  
  94. <div>Content</div>
  95. <div>Content</div>
  96. <div>Content</div>
  97. <div>Content</div>
  98.  
  99. <div>Content</div>
  100. <div>Content</div>
  101. <div>Content</div>
  102. <div>Content</div>
  103.  
  104.  
  105. <a href="#" id="loadMore">Load More</a>
  106.  
  107. <p class="totop">
  108. <a href="#top">Back to top</a>
  109. </p>
  110. </body>
  111. </html>
Advertisement
Add Comment
Please, Sign In to add comment