jquery横向滑屏滚动

柔情只为你懂 2022-08-13 04:59 255阅读 0赞
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>横向滚动</title>
  6. <style type="text/css">
  7. *{
  8. padding:0;
  9. margin:0;
  10. }
  11. ul li{
  12. list-style:none;
  13. }
  14. html{
  15. overflow:hidden;/*解决在IE6中有横向滚动条*/
  16. }
  17. body{
  18. overflow:hidden;/*解决横向滚动条问题*/
  19. }
  20. /*.outMain{
  21. overflow-x:hidden;
  22. position:relative;
  23. }*/
  24. .left{
  25. text-align:center;
  26. position:absolute;
  27. background:#CCC;
  28. width:100%;
  29. height:100%;
  30. top:0;
  31. left:0;
  32. right:0;
  33. bottom:0;
  34. z-index:1;
  35. }
  36. .right{
  37. text-align:center;
  38. position:absolute;
  39. background:#FC9;
  40. width:100%;
  41. height:100%;
  42. top:0;
  43. left:0;
  44. right:0;
  45. bottom:0;
  46. }
  47. a.clickleft{
  48. display:block;
  49. text-decoration:none;
  50. background:#099;
  51. position:absolute;
  52. z-index:2;
  53. color:#FFF;
  54. top:300px;
  55. left:0;
  56. }
  57. a.clickright{
  58. display:block;
  59. text-decoration:none;
  60. background:#09F;
  61. position:absolute;
  62. z-index:5;
  63. color:#FFF;
  64. top:300px;
  65. right:0;
  66. }
  67. </style>
  68. <script type="text/javascript" src="js/1.3.2.js"></script>
  69. <script type="text/javascript">
  70. $(function(){
  71. //$('.right').hide();
  72. $('.clickright').hide();
  73. var w=screen.width;
  74. var h=screen.height;
  75. var left=$(".left");
  76. var right=$(".right");
  77. $('.left,.right').css("height",h);/*解决在IE6下高度不能铺满全屏*/
  78. $('.clickleft').click(function(){
  79. //alert(width);
  80. left.animate({marginLeft:+w},1000);
  81. left.css("z-index","-5");
  82. right.css({"z-index":"-8","margin-left":"0"});
  83. //left.hide();
  84. //$('.right').show();
  85. //left.appendTo(right);
  86. $(this).hide();
  87. $('.clickright').show();
  88. });
  89. $('.clickright').click(function(){
  90. //alert(width);
  91. left.css({"z-index":"-10","margin-left":"0"});
  92. right.animate({marginLeft:-w},1000);
  93. $('.clickleft').show();
  94. $(this).hide();
  95. });
  96. });
  97. </script>
  98. </head>
  99. <body>
  100. <div class="outMain">
  101. <div class="left">left</div>
  102. <div class="right">right</div>
  103. </div>
  104. <a href="#" class="clickleft">left</a>
  105. <a href="#" class="clickright">right</a>
  106. </body>
  107. </html>

发表评论

表情:
评论列表 (有 0 条评论,255人围观)

还没有评论,来说两句吧...

相关阅读