JS case 6-Waterfall stream layout (1)

Source: Internet
Author: User

JS case 6-Waterfall stream layout (1)
In actual projects, a waterfall flow layout is occasionally used. Waterfall flow layout is characterized by ensuring that content blocks do not have large gaps in the horizontal direction during multi-column layout, similar to the waterfall effect. To put it simply, in the vertical list, the content block is one by one. When the content is large and not fixed, it depends on the order of the html structure, which is very limited. Here is a simple example. As long as the number and width of the list are input, the data can be dynamically put into the corresponding column. Principle 1. Define two containers. One is to store the content, and the other is to display the list. 2. Store the offsetHeight of each column in an array, obtain the smallest column, and put the data in the smallest column. When the container that stores the content is empty, it indicates that all the data in the container has been placed in the corresponding column. Note: This function must be executed after window. onload. Otherwise, the height of each content block cannot be read, leading to inaccurate offsetHeight of each column. Source code: Copy code 1 <! DOCTYPE html> 2

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.