Js implements a method similar to Sina Weibo's homepage content for gradual display, and the homepage content for gradual display

Source: Internet
Author: User

Js implements a method similar to Sina Weibo's homepage content for gradual display, and the homepage content for gradual display

The example in this article describes how js achieves a gradual effect similar to Sina Weibo's homepage content. Share it with you for your reference. The specific analysis is as follows:

Key Aspect 1:

if(list_li.length>=1){list.insertBefore(li,list_li[0]);}else{list.appendChild(li);}

Insert new content from the front. If there is no new content, insert new content to the back.

Key Aspect 2:

var height=li.offsetHeight;li.style.height='0';

Obtain the li height, and then set the li height to 0, because the height changes from 0 to the existing height.

Key Aspect 3:

startrun(li,"height",height,function(){startrun(li,"opacity","100");})

First, high change, then transparency change

Finally, run the following code:

<! DOCTYPE html> 

I hope this article will help you design javascript programs.

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.