CSS expression vs script event

Source: Internet
Author: User

National Day is coming, mobile phone station (http://www.sjjyz.com) home page also want to bring visitors a little joy feeling, so art made two flash respectively on both sides of the web page blank place, at the same time, they want to scroll along with the page and feel floating.
When implementing the rolling effect, I began to use the JS event body onscroll as usual. However, when the flash was rolled, the two Flash files felt a little choppy. Like cramps, they made people feel bad. I tried to use CSS expressions to achieve the effect and found that the result was much better, the feeling of cramps is gone at all.

CodeAs follows:

<Style>
# Flashright {} {Position:Absolute;Top:Expression (locktop ());Left:Expression (lockleft (false )); }  
# Flashleft {} {Position:Absolute;Top:Expression (locktop ());Left:Expression (lockleft (true )); }  
</Style>

 

< Script Language = " Javascript " >  
Function Locktop ()
{
VaR_ Body=Document. Body;
Return_ Body. scrolltop;
}
Function Lockleft (left)
{
If (Left)
{
Return(Screen. availwidth- 777)/2 - 134;
}
Else
{
Return(Screen. availwidth- 777)/2 + 770;
}
}
</ Script >  

The Code becomes very simple.

< Div ID = "Flashright" >

</ Div >
< Div ID = "Flashleft" >

</ Div >

The specific effect can go to the http://www.sjjyz.com to see, these two days will take this change.

 

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.