• Designs Photo
  • Fantasy Photo
  • Code Photo
  • Silhouette Photo

Creative, Modern, Professional Designs

For the last 6 years, I have been creating innovative websites to capture attention and inspire the mind, balancing user experience with an attractive website interface. By the use of AJAX and CSS, websites become more interactive, and with Search Engine Optimization, they are easily found through Google, Yahoo and Bing.

Designs Photo
Fantasy Photo

Everything you see here is Original Work

Besides the jQuery library and syntax highlighting, this whole website has been created from scratch; No pre built frameworks or content management systems have been used.

This demonstrates dedication, personalization and skill, and is reflected in all of the work I produce.

Programming is a Passion

As you get to know me, you'll start to see that I've tried my hands at just about everything, ranging from the basics to the more advanced and finer points in programming.

That means you'll probably find lots of hints and tips here for many different languages, as well as anything that I find relatively interesting!

HTML Code Photo
Silhouette Photo

Inspiring Designs with Limitless Possibilities

Every website created here is a unique one, with limiting boundaries out of the questions.

Programming is always evolving and so I'm always improving my game to keep up with the changes. You'll be able to see this reflected in the high quality work that I produce.

Anuj Nair's Blog »

Creating Multi Columned Layouts using CSS3

How to create dynamic fluid multi columned layouts using the new CSS3 selectors

Posted: 23 June 2010 - Written by Anuj Nair
A common problem which constantly crops up when developing websites is how to create an effective 2 columned or multi columned layout using CSS; a problem which frequently occurs and with what seems to be an elusive solution.

Thankfully, the W3C have come up with a solution; The CSS3 rule(s) that we are interested in are known as the column rules. Most modern browsers have all used their own prefixes on these rules until they are officially implemented as CSS3 rules:

/* Mozilla browsers */
-moz-column-width
-moz-column-gap
-moz-column-count
-moz-column-rule

/* Webkit Browsers 3 */
-webkit-column-width
-webkit-column-gap
-webkit-column-count
-webkit-column-rule

/* Opera */
-o- ...

etc.


I'll be demonstrating with the -moz- rules.

We have 2 options on tackling the issue; we can either choose to define a set number of columns using -moz-column-count - these will spread out equally over the given width to fill the whole area - or we can define a set width for each column using -moz-column-width which will fit in as many columns of the set width as possible.

Using column-width


Here's an example of how to use it:

<html>

	<head>
		<title>Multi Column Example using CSS3</title>
		<style type="text/css">
			#wrapper {
				width: 500px;
				text-align: justify;
			}
			#multi-column-example {
				-moz-column-width: 200px;
				-moz-column-gap: 15px;
			}
		</style>
	</head>
	
	<body>	
		<div id="wrapper">
			<div id="multi-column-example">
				Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis, arcu sit amet posuere fermentum, sem tellus iaculis ipsum, id iaculis sapien mi a nunc. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed mollis augue quis sem scelerisque id pellentesque dolor condimentum. Suspendisse potenti. Morbi lacinia urna tortor. Nulla facilisi. Pellentesque vestibulum augue eget nibh mollis tristique. Aliquam erat volutpat. Donec at pharetra nibh. Nullam vel leo arcu, non auctor nunc. Maecenas placerat ultrices mauris porttitor mattis. Integer tortor dui, fringilla vitae cursus tempus, faucibus vel elit. Phasellus aliquet, nulla vulputate pulvinar consequat, justo lacus consequat eros, ac pulvinar nulla elit sit amet mauris.
			</div>
		</div>
	</body>
	
</html>


The effect:



Note that there would be 70px left under this example, but only 2 columns have been created. If there isn't enough space to fix in another column, the next one will not be created. Also note that if a gap is not set, then it will default. In Firefox, this is 15px.

Using column-count


Here is the same example, with just the CSS changed:

<html>

	<head>
		<title>Multi Column Example using CSS3</title>
		<style type="text/css">
			#wrapper {
				width: 500px;
				text-align: justify;
			}
			#multi-column-example {
				-moz-column-count: 3;
				-moz-column-gap: 25px;
			}
		</style>
	</head>
	
	<body>	
		<div id="wrapper">
			<div id="multi-column-example">
				Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis, arcu sit amet posuere fermentum, sem tellus iaculis ipsum, id iaculis sapien mi a nunc. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed mollis augue quis sem scelerisque id pellentesque dolor condimentum. Suspendisse potenti. Morbi lacinia urna tortor. Nulla facilisi. Pellentesque vestibulum augue eget nibh mollis tristique. Aliquam erat volutpat. Donec at pharetra nibh. Nullam vel leo arcu, non auctor nunc. Maecenas placerat ultrices mauris porttitor mattis. Integer tortor dui, fringilla vitae cursus tempus, faucibus vel elit. Phasellus aliquet, nulla vulputate pulvinar consequat, justo lacus consequat eros, ac pulvinar nulla elit sit amet mauris.
			</div>
		</div>
	</body>
	
</html>


The effect:



3 columns will fill up the maximum area given to them.

Using column-rule


Column rules are applied in bewteen column, and are used to decorate the gaps inbetween columns, muh like a border does on an element. They are simply used like so:

-moz-column-rule: 1px solid #666;


and gives an effect like so:

Tags: CSS
Comments
No one has posted any comments yet; Why not be the first?
Name :
Email (hidden) :
Website (optional) :
Captcha :
 
How to Post   Comment :