CSS3 Multi-Column layout

Source: Internet
Author: User

In the multi-column layout, the use of bootstrap grid system can be very easy to achieve the effect, in fact, CSS3 itself also provides the function of the Dolan layout.

For example, we populate a tag with a section lot of content, and want the content to be displayed in three columns, you can use the following CSS to implement ( using Chrome browser ).


Set the number of columns
section {  -webkit-column-count:3;}

According to the width of the column
section {  -webkit-column-width:25rem;}

rem In contrast em , the font size it represents is relative to the global.

If you can display some markup in the column gap, the page will look more beautiful and its implementation is very simple.


Defining the compartment gap
section {  -webkit-column-width:25rem;  -webkit-column-rule:3px solid #8B2101;  -webkit-column-gap:2rem;

It column-rule can be split into the following rules:

    • column-rule-width: 3px;
    • column-rule-style: solid;
    • column-rule-color: #8B2101;

If you do not define the height of the column, the content is evenly distributed, but if you specify a height, you can also perform a column fill.


How column contents are filled
section {  column-width:20rem;  column-rule:3px solid #8B2101;  Column-gap:2rem;  Height:85rem;  Column-fill:balance;}

column-fillIn addition to the value balance , there is another valueauto


How to Hurdle

In the table we can use colspan=2 to configure the content extension of the number of columns, of course, the contents of the column can also be implemented as follows.

Section img {   column-span:all;   Margin:1rem Auto;}

Other features

Tell the browser where you want to start the column.
Break-before
Auto\always\avoid\column\avoid-column
Break-after
Auto\always\avoid\column\avoid-column
Break-inside
Auto\always\avoid\column\avoid-column

Reference

"CSS real-combat development and design"

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.