<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Saucer Blog &#187; CSS</title>
	<atom:link href="http://www.saucer.dk/category/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.saucer.dk</link>
	<description></description>
	<lastBuildDate>Mon, 18 Oct 2010 17:54:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Dynamic columns without using JavaScripts</title>
		<link>http://www.saucer.dk/2009/09/dynamic-columns-without-using-javascripts/</link>
		<comments>http://www.saucer.dk/2009/09/dynamic-columns-without-using-javascripts/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 20:48:35 +0000</pubDate>
		<dc:creator>Srdjan</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS columns]]></category>
		<category><![CDATA[Dynamic]]></category>

		<guid isPermaLink="false">http://saucer.dk/?p=4</guid>
		<description><![CDATA[We all remember how easy it was to make a website with 2,3 or even more columns by using &#60;table&#62; design. The way the cells ware attached to each other in &#60;table&#62;&#8217;s maid it easy for webdevelopers to have a background color in one of the columns that was following maximum height of the heighest [...]]]></description>
			<content:encoded><![CDATA[<p>We all remember how easy it was to make a website with 2,3 or even more columns by using &lt;table&gt; design. The way the cells ware attached to each other in &lt;table&gt;&#8217;s maid it easy for webdevelopers to have a background color in one of the columns that was following maximum height of the heighest column. Today we all use &lt;table&gt; less designs since &lt;table&gt;&#8217;s are to slow and &#8220;hard&#8221; to controle when we talk about cross browser-optimation. So here I&#8217;m going to show you a small and easy fix in how you can get the same effect with your &lt;div&gt; designs without using JavaScripts or any kind of fancy CSS hacks that might not work in other browsers.</p>
<h2>Layout</h2>
<p>Lets say that you wanna make a simple website with 2 columns. One for yur navigation and the other for the content area.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;master&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;navigation&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;content&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></td></tr></table></div>

<h2>CSS</h2>
<p>Lets just make up something quick, after all it is just a demo :)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#master</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">500px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">600px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#000000</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#navigation</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">600px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">border-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#000000</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#eeeeee</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#content</span><span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">600px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>So, what we have here is basicly a very simple setup, where our columns have 600px heigh.<br />
The height is static and if we make our #content heigher or lower then our #navigation then<br />
our #navigation won&#8217;t be effected, since it&#8217;s height is not dynamic and our &lt;div&gt;&#8217;s arnt linked<br />
together. Now this is the place where some webdevelopers start to use all kind of tricks with<br />
JavaScripts, but there is a very simple and easy way of making this just by using CSS as we know it.</p>
<h2>CSS step 2</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#master</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">500px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">600px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#000000</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#navigation</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">600px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">border-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#000000</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#eeeeee</span><span style="color: #00AA00;">;</span>
margin-botttom<span style="color: #00AA00;">:</span><span style="color: #933;">-32000px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">padding-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">32000px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#content</span><span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">600px</span><span style="color: #00AA00;">;</span>
margin-botttom<span style="color: #00AA00;">:</span><span style="color: #933;">-32000px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">padding-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">32000px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<h2>Explanation</h2>
<p>As you can see the code is very simple and what we basicly did was just to make the #master with overflow:hidden and maid our heights dynamic by using min-height + our two columns have a small trick with margin and padding, that makes a 32000px height &#8220;buffer&#8221; wich is hidden by the overflow:hidden on our #master. Now the reason why our #master now is dynamic is because we havent sat a static height on it. So eachtime our colums get longer the overflow will show more and more of our 32000px buffer.</p>
<p>At the end I wanna wish you all happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.saucer.dk/2009/09/dynamic-columns-without-using-javascripts/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

