23 lines of Jquery code to implement special effect on waterfall stream Layout

Source: Internet
Author: User

I have seen this Jquery special effect on the Internet. I can see that the code is very concise, and there are only 23 lines of Jquery Code implementing waterfall stream layout. I personally feel very good, later, I asked my original author sole if he could share the work on the JquerySchool website so that more users could learn it, after reading the reply today, I will immediately sort it out and share it with you...

 

The 23 lines of core Code are as follows:

Var cases = $ ("# case-list li"); var case_h = [[], [], [], []; var sum = [0, 0, 0]; $. each (cases, function (I) {var m = I % 4; var step = Math. floor (I/4); cases.eq(i2.16.css ("left", 220 * m + "px"); case_h [m]. push (cases. eq (I ). height (); if (! Step) {cases.eq(i2.16.css ("top", "0") ;}else {var num = 0; for (var n = 0; n <step; n ++) {num + = case_h [m] [n] + 20;} cases.eq(iyun.css ("top", num + "px") ;}}); $ (case_h ). each (function (I) {$ (case_h [I]). each (function (j) {sum [I] + = case_h [I] [j]; Aggregate aggregate into aggregate cases.parent().css ("height", sum. sort (function (a, B) {return a <B? A:-1}) [0] + 100 + "px ");

 

 

The effect is as follows:

 

Online Demo and download

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.