CSS multi-column layout

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

The CSS multi-column layout module lets you divide content across multiple columns. By using the properties in this module, you can define the preferred number and width of columns, the gap size between columns, and the visual appearance of the optional column dividing lines (known as column rules). You can also define how content should flow from column to column and how to break content between columns.

Multi-column layout in action

In this example, the 1967 speech from Canada's centennial, _A Lament for Confederation_, by Chief Dan George, is displayed across multiple columns, similar to the way articles are displayed in printed newspapers. If you have JavaScript enabled, controls enable changing the preferred column number and width, the width of the gap between columns, whether the title and a sample blockquote should be contained in a single column or made to span all columns, and whether breaking within the paragraphs should be avoided.

html hidden live-sample___multicol
js hidden live-sample___multicol
css hidden live-sample___multicol

{{EmbedLiveSample("multicol", "", "800px")}}

توجه: Multiple-column layout is closely related to paged media. Each column box is a fragment, much like each printed page is a fragment of a document. Using the properties defined in the CSS fragmentation module, you can control how content breaks between columns and pages.

Reference

Properties

  • {{cssxref("column-fill")}}
  • {{cssxref("column-span")}}
  • {{cssxref("columns")}} shorthand
  • {{cssxref("column-count")}}
  • {{cssxref("column-height")}}
  • {{cssxref("column-width")}}
  • {{cssxref("column-wrap")}}

توجه: Bear in mind that setting container height and line length can pose challenges for people with visual or cognitive disabilities. WCAG Success Criterion 1.4.8 states that even when the text size is doubled, content should not need to be scrolled.

Selectors and pseudo-elements

  • {{cssxref("::column")}}

Guides

Related concepts

CSS gaps module

  • {{cssxref("column-rule")}} shorthand
  • {{cssxref("column-rule-color")}}
  • {{cssxref("column-rule-style")}}
  • {{cssxref("column-rule-width")}}
  • {{cssxref("gap")}} shorthand
  • {{cssxref("column-gap")}}
  • {{cssxref("row-gap")}}
  • {{cssxref("row-rule")}}
  • {{cssxref("rule")}} shorthand
  • {{cssxref("rule-break")}}
  • {{cssxref("rule-color")}}
  • {{cssxref("rule-inset")}}
  • {{cssxref("rule-overlap")}}
  • {{cssxref("rule-style")}}
  • {{cssxref("rule-width")}}

CSS fragmentation module

  • {{cssxref("break-after")}}
  • {{cssxref("break-before")}}
  • {{cssxref("break-inside")}}
  • {{cssxref("orphans")}}
  • {{cssxref("widows")}}

CSS box alignment module

  • {{cssxref("gap")}}

CSS box sizing module

  • {{cssxref("height")}}
  • {{cssxref("max-height")}}
  • {{cssxref("block-size")}}
  • {{cssxref("width")}}
  • {{cssxref("max-width")}}

CSS overflow module

  • {{cssxref("overflow")}}
  • {{cssxref("::scroll-marker")}}
  • {{cssxref("::scroll-marker-group")}}
  • {{glossary("Scroll container")}} glossary term

CSS display module

Specifications

{{Specifications}}

See also