JQuery scrolling effect code with scroll bar

Source: Internet
Author: User
Tags prev

JQuery scrolling effect with scroll bar (fixed version)
Code (based on jquery):

The code is as follows Copy Code

Side Bar with move
var Rollstart = $ ('. Feed-mail '),//when scrolling to this block begins to move
Rollset = $ ('. Search,.weibo,.group,.feed-mail,.tags '); Move blocks before adding rollstart

Rollstart.before (' <div class= "Da_rollbox" style= "Position:fixed;background-color: #fff; width:inherit;" ></div> ');
var offset = Rollstart.offset (), Objwindow = $ (window), Rollbox = Rollstart.prev ();
Objwindow.scroll (function () {
if (Objwindow.scrolltop () > Offset.top) {
if (rollbox.html (null)) {
Rollset.clone (). Prependto ('. Da_rollbox ');
}
Rollbox.show (). Stop (). Animate ({top:0,paddingtop:15},400);
} else {
Rollbox.hide (). Stop (). Animate ({top:0},400);
}
});

More simple than the last, please note that the place, you need to add the module class or ID according to your requirements. It is worth noting that the background color of line fifth, the default is white!

TIPS:IE6 fans can add code that doesn't support fixed

JQuery scrolling effect with scroll bar (for content page long articles)


jquery scrolling follower block, the code is as follows:

The code is as follows Copy Code

//sidebar follow
var Rollstart = $ ('. Feed-mail '),//when scrolling to this block begins with the
 rollout = $ ('. Cookie-list ');//Hide the blocks after Rollstart

Rollstart.before (' <div class= ' da_rollbox ' ></div> ');

var offset = Rollstart.offset (), Objwindow = $ (window), Rollbox = Rollstart.prev (),
 rollset = $ ('. Search,. Weibo,.group '); The following block

Objwindow.scroll (function () {
 if (objwindow.scrolltop () > Offset.top) {
& Rollstart before adding the Nbsp; if (rollbox.html (null)) {
   rollset.clone (). Prependto ('. Da_rollbox ');
  &NBSP}
  rollout.fadeout ();
  rollbox.show (). Stop (). Animate ({margintop: Objwindow.scrolltop ()-offset.top + 20},400);
 } else {
  rollout.fadein ();
  rollbox.hide (). Stop (). Animate ({margintop:0}, 400);
 }
});

There is already a full comment in the code, just write a few class or ID (preferably not id,w3c the ID cannot be reused

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.