CSS layout instance series (4) How does one implement the change of the number of sub-containers in each row of the container along with the change of the browser width ?, Css container

Source: Internet
Author: User

CSS layout instance series (4) How does one implement the change of the number of sub-containers in each row of the container along with the change of the browser width ?, Css container

Hello, boys, do you remember who I am? By the way, I am ~ Chaowei ~ Well, let's get down to the point. Today's layout example is:

Implement a floating layout. The number of blue containers in each row in the red container changes with the browser width, as shown in the following figure:

Someone must have been jealous ~ It's so simple, it's not just a float of the left, it's worth mentioning? Don't worry. In fact, there are still a lot of pitfalls in it, and I will fill them one by one.

1. Implement through left floating 2. Implement through inline-block

Can this instance be completed only through left floating? No, we still have inline-block. The inline-block can be arranged horizontally as the elements in the row, but the content of the box still conforms to the behavior of the block-level box. With this feature, we can use the inline-block to create a lot of mesh-filled containers like float, without the need to clear the float. Of course, the entire layout process is easier than the left floating, as shown in the following DEMO:

See the Pen inline-block-container by xal821792703 (@ honoka) on CodePen.

Finally, I would like to thank you for reading this article. Welcome to my repo to check the source code. If you have any questions, please feel free to speak to me.

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.