Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> the scroll bar drop-down DIV is fixed to the head. </title>
<Script type = "text/javascript" src = "http://img.fishburg.net/ks/js/jquery-1.8.js"> </script>
<Style>
* {Padding: 0; margin: 0 ;}
. AB {width: 100%; background-color: # eee; height: 250px; text-align: center; line-height: 250px ;}
. Bc {width: 100%; background-color: # eee; text-align: center; color: # fff; font-size: 24px; background-color: #060 ;}
. Pf {width: 100%; height: 50px; background-color: # C00; text-align: center; line-height: 50px; color: # fff ;}
/* --------------------- Floating navigation ---------------------------*/
Html {_ background-image: url (about: blank); _ background-attachment: fixed;/** prevent ie6 jitter **/}
. Float {position: fixed; z-index: 999999; top: 0px ;}
* Html. float {position: absolute; _ top: expression (documentElement. scrollTop-0 );}
</Style>
</Head>
<Body>
<Div class = "AB"> first block </div>
<Div class = "pf"> floating content </div>
<Script type = "text/javascript">
Window. onscroll = function (){
If ($ (document). scrollTop () & gt; 250)
{
// $ ("# Pf_nav"). show ();
$ (". Pf"). addClass ('float ');
} Else {
// $ ("# Pf_nav"). hide ();
$ (". Pf"). removeClass ('float ');
}
}
</Script>
<Div class = "bc">
<P>
<Script language = "javascript">
For (I = 0; I <50; I ++ ){
Document. write (I + "<br/> ");
}
</Script>
</P>
</Div>
</Body>
</Html>