Several solutions to implement rolling Advertisement Using JS or CSS

Source: Internet
Author: User

The scroll event in JS is triggered, but what I encountered is really not moving. I thought it would be like this only on ff. I didn't expect IE6 and IE7 to have this effect, you have to be amazed.
If so, I found the following magic: Code : Only use CSS to implement the scrolling effect ~~
# Fixed {position: fixed ;}

<Div id = "fixed"> scroll </div>

After that, the attribute will be rolled over. I really want to swear. But it's not over yet. This only supports Firefox and IE7. I just said that IE6 is fine, but it's a bit complicated to implement IE6,

Copy code The Code is as follows: <! -- [If IE]>
<Style type = "text/CSS">
* Html # fixed {position: absolute; Right: 1px; top: expression_r (eval_r (document. Body. height + 500 ));}
* HTML {overflow: hidden ;}
* Html body {Height: 100%; overflow: auto ;}
* Html # fixed {right: 17px; top: 5em ;}
* Html # fixed {right: 1px; top: expression_r (eval_r (document. Body. height + 500 ));}
</Style>
<! [Endif] -->

I am not sure what it means. It's like CSS, but it should be a script !? Some people may know how to share it with you.
Since I use n methods to implement scrolling, it is certainly not just these two methods. As if there are other CSS statements, I will not list them one by one. I mainly want to tell you the common JS implementation methods. My website uses a piece of code and is also found online, however, a bad thing is that it is relative to the top, that is, if your webpage is not highly enough, it will be unable to be pulled to the end. In fact, Baidu's message will also be in this situation, I will not talk much about it. I will post it for you to see:Copy codeThe Code is as follows: lastscrolly = 0;
Function HEARTBEAT (){
VaR diffy;
If (document.doc umentelement & document.doc umentelement. scrolltop)
Diffy = document.doc umentelement. scrolltop;
Else if (document. Body)
Diffy = Document. Body. scrolltop
Else
{}
Percent =. 1 * (diffy-lastscrolly );
If (percent> 0) percent = math. Ceil (percent );
Else percent = math. Floor (percent );
Document. getelementbyid ("lovexin12"). style. Top = parseint (document. getelementbyid ("lovexin12"). style. Top) + percent + "PX ";
(Document. getelementbyid ("lovexin12"). style. Top) + percent + "PX ";

Lastscrolly = lastscrolly + percent;
}

Window. setinterval ("Heartbeat ()", 1 );

If you are interested, you can change the above to the lower part, which will be much better.
I have been reading the JS library recently. jquery is quite interesting. So ~, Now I will paste a code that uses jquery to implement scrolling, which is much better than above. However, it is only a choice, and there is no need to use it. In fact, jquery's Code also has dozens of kb.

Copy code The Code is as follows: $ (document). Ready (function (){

If ($. browser. MSIE & $. browser. Version = 6 ){
Followdiv. Follow ();
}
});
Followdiv = {
Follow: function (){
('Your cssrain').css ('position', 'absolute ');
$ (Window). Scroll (function (){
VaR f_top = $ (window ). scrolltop () + $ (window ). height ()-$ ("# cssrain "). height ()-parsefloat ($ ("# cssrain" ).css ("bordertopwidth")-parsefloat ($ ("# cssrain" ).css ("borderbottomwidth "));
Certificate ('your cssrain').css ('top', f_top );
});
}
}

Okay, let's talk about it !! You can raise any questions you don't understand! The discussion will make progress ~! You are welcome to join our QQ Group to learn and make progress together. Group No.: 5678537

Related Article

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.