Monday 12 October 2015

CSS3 Multiple Columns

CSS3 Multiple Columns

With CSS3, you can create multiple columns for laying out text - like in newspapers!
In this chapter you will learn about the following multiple column properties:
  • column-count
  • column-gap
  • column-rule


Browser Support

PropertyBrowser Support
column-count-moz--webkit--webkit-
column-gap-moz--webkit--webkit-
column-rule-moz--webkit--webkit-
Internet Explorer and Opera do not yet support the multiple columns properties.
Firefox requires the prefix -moz-.
Chrome and Safari require the prefix -webkit-.

CSS3 Create Multiple Columns

The column-count property specifies the number of columns an element should be divided into:
SafariChromeFirefoxInternet Explorer

Example

Divide the text in a div element into three columns:
div
{
-moz-column-count:3; /* Firefox */
-webkit-column-count:3; /* Safari and Chrome */
column-count:3;
}

Try it yourself »


CSS3 Specify the Gap Between Columns

The column-gap property specifies the gap between the columns:
SafariChromeFirefoxInternet Explorer

Example

Specify a 40 pixels gap between the columns:
div
{
-moz-column-gap:40px; /* Firefox */
-webkit-column-gap:40px; /* Safari and Chrome */
column-gap:40px;
}

Try it yourself »


CSS3 Column Rules

The column-rule property sets the width, style, and color of the rule between columns.
SafariChromeFirefoxInternet Explorer

Example

Specify the width, style and color of the rule between columns:
div
{
-moz-column-rule:3px outset #ff00ff; /* Firefox */
-webkit-column-rule:3px outset #ff00ff; /* Safari and Chrome */
column-rule:3px outset #ff00ff;
}

Try it yourself »


New Multiple Columns Properties

PropertyDescriptionCSS
column-countSpecifies the number of columns an element should be divided into3
column-fillSpecifies how to fill columns3
column-gapSpecifies the gap between the columns3
column-ruleA shorthand property for setting all the column-rule-* properties3
column-rule-colorSpecifies the color of the rule between columns3
column-rule-styleSpecifies the style of the rule between columns3
column-rule-widthSpecifies the width of the rule between columns3
column-spanSpecifies how many columns an element should span across3
column-widthSpecifies the width of the columns3
columnsA shorthand property for setting column-width and column-count3

No comments:

Post a Comment