33Jazzing Up Layouts with Columns

Say we want to make our website look more like a newspaper. We want to turn our boring one-column paragraph into multiple columns. This is a lot easier with Compass.

We have the option to apply any number of columns. We can use two extra mixins to define the width of each column as well as the gap between each column.

If necessary, we can add a line to separate the columns of text. The declarations we use are the same as what we would use for describing a regular border, namely the width, style, and color.

It’s important to note that columns aren’t really supported in older versions of Internet Explorer. Also, the column attribute doesn’t really like it if you define heights.

What To Do...
  • Turn text into columned text.
    compass/columns.scss
     
    #two_columns {
     
    @include​ column-count(2);
     
    width: 300px; }
  • Define the width of columns and the gap between columns.
     
    @include​ column-width(240px);
     
    @include​ column-gap(24px);
  • Add a border between the columns.
    compass/columns.scss
     
    #columns_borders {
     
    @include​ column-count (3);
     
    @include​ column-rule(2px, dashed, #336699);
     
    width: 300px; }
  • See how these look in the browser.
    images/compass/column_examples.png

Related Tasks

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset