The technique of realizing the sliding _javascript of div layer following scroll bar based on JavaScript

Source: Internet
Author: User

In a page to put 2 floating box, the hover box with the page scroll up and down the effect of fluctuation, and finally fixed in the same position

The effect is shown as follows:

The code is as follows:

<! DOCTYPE html>  

Here to share a piece of code page at the top of the fixed Div, do not move with the scroll bar, prompting browser information

Example 1:

 

Example 2:

<style type= "Text/css" >
{
margin:0px;
padding:0px;
}
Body {
background-attachment:fixed/* Prevent screen flash in IE6/
}
#topNavWrapper {
width:100%;
   text-align:left;
height:28px;
margin:0px Auto;
z-index:100;
_position:relative;
_top:0px;
}
#topNav {
width:100%;
Float:left;
Display:block;
z-index:100;
overflow:visible;
position:fixed;
top:0px; /* Position fixed for IE6 * *
_position:absolute;
_top:expression (documentelement.scrolltop + "px");
height:28px;
}
</style>

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.