Advertisement
Guest User

Untitled

a guest
Jul 1st, 2015
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. <script type="text/javascript">
  2. $(document).ready(function(){
  3. var first = $('.item').first(),
  4. last = $('.item').last(),
  5. itemWidth = first.width(),
  6. carousel = $('.carousel');
  7.  
  8. carousel.prepend(last.clone()).append(first.clone());
  9. carousel.width(itemWidth * $('.item').length);
  10. carousel.css({left: -itemWidth});
  11.  
  12. $('.prev').on('click', function(e){
  13. e.preventDefault();
  14. carousel.animate({left: '+=' + itemWidth},300,function(){
  15. if(Math.abs(carousel.position().left)<2){
  16. carousel.css({left: -itemWidth * (carousel.children().length-2)});
  17. }
  18. });
  19. return false;
  20. });
  21.  
  22. $('.next').on('click', function(e){
  23. e.preventDefault();
  24. carousel.animate({left: '-=' + itemWidth},300,function(){
  25. if(Math.abs(carousel.position().left + itemWidth * (carousel.children().length - 1))<2){
  26. carousel.css({left: -itemWidth});
  27. }
  28. });
  29. return false;
  30. });
  31. });
  32. </script>
  33.  
  34. <style media="screen">
  35.  
  36. .container{
  37. width : 100%;
  38. }
  39.  
  40. .carousel-wrapper{
  41. position : relative;
  42. width : 100%;
  43. height : 100%;
  44. overflow : hidden;
  45. }
  46.  
  47. .carousel{
  48. position : absolute;
  49. }
  50.  
  51. .carousel li{
  52. display : block;
  53. float : middle;
  54. width : 100%;
  55. height : 100%a;
  56. position : relative;
  57. }
  58.  
  59. .carousel img{
  60. position : absolute;
  61. z-index : 0;
  62. }
  63.  
  64. .carousel-nav a{
  65. display : block;
  66. height : 40px;
  67. width : 30px;
  68. font-size : 24px;
  69. line-height : 1.6;
  70. font-weight : 800;
  71. background-color : rgba(255,99,71,0.1);
  72. text-decoration : none;
  73. position : absolute;
  74. top : 50%;
  75. text-align : center;
  76. z-index : 10;
  77. }
  78.  
  79. .carousel-nav a.prev{
  80. left : 0;
  81. -webkit-border-top-right-radius:4px;
  82. -webkit-border-bottom-right-radius:4px;
  83. }
  84.  
  85. .carousel-nav a.next{
  86. right : 0;
  87. -webkit-border-top-left-radius:4px;
  88. -webkit-border-bottom-left-radius:4px;
  89. }
  90.  
  91. </style>
  92.  
  93. <div class="container">
  94. <div class="carousel-wrapper">
  95. <ul class="carousel">
  96. <li class="item">
  97. <object>
  98. <embed src="langs.svg" height="100%" width="100%">
  99. </object>
  100. </li>
  101. <li class="item">
  102. <object>
  103. <embed src="mmedia.svg" height="100%" width="100%">
  104. </object>
  105. </li>
  106. <li class="item">
  107. <object>
  108. <embed src="langs.svg" height="100%" width="100%">
  109. </object>
  110. </li>
  111. <li class="item">
  112. <object>
  113. <embed src="mmedia.svg" height="100%" width="100%">
  114. </object>
  115. </li>
  116. </ul>
  117. <div class="carousel-nav">
  118. <a href="" class="prev"><</a>
  119. <a href="" class="next">></a>
  120. </div>
  121. </div>
  122. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement