肥宅综合社区-做一个优雅文明的综合社区

搜索内容

超长网页如何让右侧DIV跟随滚动窗口往下滚动?

2023-09-24 555阅读 14评论

  1. document

  2. *{ margin:0; padding:0;}
  3. body { font:12px/1.8 Arial; color:#666;}
  4. h1.tit-h1 { font-size:38px; text-align:center; margin:30px 0 15px; color:#f60;}
  5. .go-back{ text-align:center; border-top:1px dashed #ccc; padding:10px; margin-top:20px; font-size:40px;}
  6. .wrap{border:1px dashed #ccc; background:#f8f8f8; padding:20px;}

  7. .demo { height:1500px; }
  8. .float { width:200px; padding:5px 10px; border:1px solid #ffecb0; font-size:12px; background-color:#fffee0; -moz-box-shadow:1px 1px 2px rgba(0,0,0,.2); -webkit-box-shadow:1px 1px 2px rgba(0,0,0,.2); box-shadow:1px 1px 2px rgba(0,0,0,.2); position:absolute; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; }
  9. .float .close-ico{ position:absolute; top:5px; right:5px; display:block; width:16px; height:16px; }






  10. /**
  11. * @author 愚人码头
  12. * 类似于新浪微博新消息提示的定位框
  13. * 更多
  14. */
  15. (function($){
  16.     $.fn.capacityFixed = function(options) {
  17.         var opts = $.extend({},$.fn.capacityFixed.deflunt,options);
  18.         var FixedFun = function(element) {
  19.             var top = opts.top;
  20.             var right = ($(window).width()-opts.pageWidth)/2+opts.right;
  21.             element.css({
  22.                 "right":right,
  23.                 "top":top
  24.             });
  25.             $(window).resize(function(){
  26.                 var right = ($(window).width()-opts.pageWidth)/2+opts.right;
  27.                 element.css({
  28.                     "right":right
  29.                 });
  30.             });
  31.             $(window).scroll(function() {
  32.                 var scrolls = $(this).scrollTop();
  33.                 if (scrolls > top) {

  34.                     if (window.XMLHttpRequest) {
  35.                         element.css({
  36.                             position: "fixed",
  37.                             top: 0                           
  38.                         });
  39.                     } else {
  40.                         element.css({
  41.                             top: scrolls
  42.                         });
  43.                     }
  44.                 }else {
  45.                     element.css({
  46.                         position: "absolute",
  47.                         top: top
  48.                     });
  49.                 }
  50.             });
  51.             element.find(".close-ico").click(function(event){
  52.                 element.remove();
  53.                 event.preventDefault();
  54.             })
  55.         };
  56.         return $(this).each(function() {
  57.             FixedFun($(this));
  58.         });
  59.     };
  60.     $.fn.capacityFixed.deflunt={
  61.         right : 100,//相对于页面宽度的右边定位
  62.         top:150,
  63.         pageWidth : 960
  64.     };
  65. })(jQuery);




  66.     你是谁

  67. 哥是来占位的
  68. 哥是来占位的
  69. 哥是来占位的
  70. 哥是来占位的
  71. 哥是来占位的
  72. 哥是来占位的
  73. 哥是来占位的
  74. 哥是来占位的
  75. 哥是来占位的
  76. 哥是来占位的
  77. 哥是来占位的
  78. 哥是来占位的
  79. 哥是来占位的
  80. 哥是来占位的
  81. 哥是来占位的
  82. 哥是来占位的
  83. 哥是来占位的
  84. 哥是来占位的
  85. 哥是来占位的
  86. 哥是来占位的
  87. 哥是来占位的
  88. 哥是来占位的
  89. 哥是来占位的
  90. 哥是来占位的
  91. 哥是来占位的
  92. 哥是来占位的
  93. 哥是来占位的
  94. 哥是来占位的
  95. 哥是来占位的
  96. 哥是来占位的
  97. 哥是来占位的
  98. 哥是来占位的
  99. 哥是来占位的
  100. 哥是来占位的
  101. 哥是来占位的
  102. 哥是来占位的
  103. 哥是来占位的
  104. 哥是来占位的
  105. 哥是来占位的
  106. 哥是来占位的
  107. 哥是来占位的
  108. 哥是来占位的

  109. $("#float").capacityFixed();

  110.      







文章版权声明:本站部分内容系网络转载,如果文章触发到您的利益或版权,请联系本站客服邮箱kefu@fz331.com删除,我们将48小时之内删除。

发表评论

上传附件:
评论列表 (有 14 条评论,555人围观)
网友昵称:肥宅
肥宅V铁粉
2023-09-27 回复
aaaaaaaaaaaaaa
网友昵称:肥宅
肥宅V铁粉
2023-09-25 回复
@肥宅
我想对你说:
测试看看啊
网友昵称:肥宅
肥宅V铁粉
2023-09-25 回复
收拾收拾收拾收拾收拾收拾收拾
网友昵称:肥宅
肥宅V铁粉
2023-09-25 回复
撒啊啊啊啊啊啊啊啊啊啊啊啊啊
网友昵称:肥宅
肥宅V铁粉
2023-09-25 回复
@肥宅
我想对你说:
1111111111111111
网友昵称:肥宅
肥宅V铁粉
2023-09-25 回复
@肥宅,[br]我想对你说:[br]aaaaaaaaaaaaaaa
网友昵称:肥宅
肥宅V铁粉
2023-09-25 回复
@肥宅aaaaaaaaaaaa
网友昵称:肥宅
肥宅V铁粉
2023-09-25 回复
@aaaaaaaaaaaaa
网友昵称:肥宅
肥宅V铁粉
2023-09-25 回复
sssssssssss
网友昵称:肥宅
肥宅V铁粉
2023-09-25 回复
1111111111111
切换注册

登录

忘记密码?

切换登录

注册

验证码