CSS3 Box with Multiple Columns

Create multiple columns with CSS3 column-count and column-gap properties

Creative CSS

Designing with CSS – Multiple Columns

You may have multi-column layouts using CSS3 which allows content to flow into multiple columns with a gap and a rule between them.

There are ten properties to extend the current CSS box model, out of which I have used three in the examples in this article. These properties allow you to have multiple columns, in two ways: by defining a width for each column, or by defining a number of columns. To create a space between the columns, you need to specify a width for gaps, and may even insert rules.

CSS3 Generator

If you are not very comfortable with CSS, or would like to have CSS codes auto-generated for you to save time, here is a useful and handy tool called CSS3 Generator. This simple tool created by Randy Jensen could be used for most basic design elements like rounder corners, box-shadow, text-shadow, etc on your webpages. It will create some cross-browser CSS3 code based on whatever values you want.

In the previous article I illustrated generation of code for text shadow using text-shadow property of CSS3 with the help of this tool.

In this article I shall illustrate generation of code for multiple columns using column-count, column-width, column-gap and column-rule properties of CSS3 with the help of this tool. The procedure is simple. You chose your design element from the drop-down menu, enter your values, and get your auto-generated code for your project.

Multiple Columns

You enter the number of columns you want to create within the box, and the column gap in between columns. The code will be generated.

Your Code:

-moz-column-count:2;
-moz-column-gap:10px;
-webkit-column-count:2;
-webkit-column-gap:10px;
column-count:2;
column-gap:10px; 

Browser Compatibility:

Firefox 3.0+ Chrome 4.0+ Safari 3.1+

Example of Box with Multiple Columns

This example uses the CSS3 column-count property and currently it will not work in all browsers. Alternatively, you may also use the CSS3 column-width property to create multiple columns. I am giving you the code for CSS3 column-width property as well.

You set gaps and rules between two adjacent columns using the CSS3 column-gap and column-rule properties. The values of the column-rule property are similar to those of the CSS border properties. Like border, column-rule is a shorthand property.

CSS Code:

.box {color:#807970;background:#f9fafa;border:1px solid #dbe1e6}
.corner {border-radius:10px;-moz-border-radius:10px;-webkit-border-radius:10px}
.twocolumns-count {column-count:2;column-gap:10px;-moz-column-count:2;-moz-column-gap:10px;-webkit-column-count:2;-webkit-column-gap:10px}
.twocolumns-width {column-width:300px;column-gap:10px;-moz-column-width:300px;-moz-column-gap:10px;-webkit-column-width:300px;-webkit-column-gap:10px;}

HTML:

<div class="box corner twocolumns-count">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 
</div>

Example without Rule:

CSS3 Box with Multiple Columns
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

CSS Code:

.box {color:#807970;background:#f9fafa;border:1px solid #dbe1e6}
.corner {border-radius:10px;-moz-border-radius:10px;-webkit-border-radius:10px}
.twocolumns-rule {column-count:2;column-gap:10px;column-rule:1px solid #dbe1e6;-moz-column-count:2;-moz-column-gap:10px;-moz-column-rule:1px solid #dbe1e6;-webkit-column-count:2;-webkit-column-gap:10px;-webkit-column-rule:1px solid #dbe1e6}

HTML:

<div class="box corner twocolumns-rule">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 
</div>

Example with Rule:

CSS3 Box with Multiple Columns
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
Browser Support
Multi-column layout is currently only supported in Mozilla based browsers and Safari 3, who have prefixed the properties with respectively -moz and -webkit.

Firefox 1.5 (Gecko 1.8) and later support the CSS properties -moz-column-count, -moz-column-width, and -moz-column-gap.

CSS3 Generator
W3C CSS3 Draft Module
This specification describes multi-column layouts in CSS, a style sheet language for the web. Using functionality described in the specification, content can be flowed into multiple columns with a gap and a rule between them.

CSS Multi-Column Layout Module
Web Host for your WordPress Blog
If you are looking for a web host that will provide hosting environment for WordPress, BlueHost is one of the best choices. My website and blog are hosted by BlueHost.

Click Here to Signup for BlueHost
Small Business Website Design
Get a professionally designed special custom five-page website ideal for small business that need an online presence as well as personal sites or informational sites at an amazing price of only $125.
Visit our website to learn more about Small Business Website Design

Previous Article
Next Article
CSS3 Text with Shadow
Create text shadow with CSS3 text-shadow property
 
Related Posts with Thumbnails
Admin/Author Admin/Author: Subrato Paul, owner of GoldenTwine Informatics founded in April 2003, lives in Kolkata, India. He is a freelance website designer, Internet marketer, social media enthusiast, and blogger. He writes in his blogs and as a guest writer about marketing and social media, eCommerce, website design and development, and his website.
RSSDid you like this article? If you're new to goldenTwine blog, you may want to
Subscribe to RSS feed: | Comments RSS | Email Subscription
Social Media:
Short Link: https://wp.me/pPMoR-lM | Thanks for visiting!

2 Comments

  1. I have recommended this article to my friend who wanted to learn about the CSS3. I, myself have not yet experienced using the CSS3 but is still learning. Subrato Paul, your articles have helped us and have given us lot information when it comes in doing codes.

  2. Labelle
    | Permalink

    Great tool! I often struggle with column layouts layouts in css and sometimes end up using tables.

One Trackback

Post a Comment

Your email is never published nor shared. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*
*

Notify me of followup comments via e-mail. You can also subscribe without commenting.

This site uses Akismet to reduce spam. Learn how your comment data is processed.