<?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>LUXE WEB MEDIA &#124; Freelance Web Design &#38; Development</title>
	<atom:link href="http://www.luxewebmedia.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.luxewebmedia.com</link>
	<description>Freelance Web Design &#38; Development</description>
	<lastBuildDate>Thu, 08 Jul 2010 21:48:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>CSS Floated Div Elements and Container Height</title>
		<link>http://www.luxewebmedia.com/2010/07/08/css-floated-div-elements-and-container-height/</link>
		<comments>http://www.luxewebmedia.com/2010/07/08/css-floated-div-elements-and-container-height/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 21:41:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[container height]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[div container height]]></category>
		<category><![CDATA[floated div]]></category>
		<category><![CDATA[floated elements]]></category>
		<category><![CDATA[xhtml. html]]></category>

		<guid isPermaLink="false">http://www.luxewebmedia.com/?p=203</guid>
		<description><![CDATA[You may be used to using a div container to center-align floated elements. This is a common practice for me&#8211; you set the container width and the right/left margins to auto. See the example below:
XHTML Markup
&#60;div id=&#8221;container&#8221;&#62;
&#60;div id=&#8221;floated_left_inner_element&#8221;&#62;&#60;/div&#62;
&#60;div id=&#8221;floated_right_inner_element&#8221;&#62;&#60;/div&#62;
&#60;/div&#62;

CSS
#container {
width:900px;
margin-right:auto;
margin-left:auto;
background-color:#CCCCCC;
}
#floated_left_inner_element{
width:350px;
float:left;
}
#floated_right_inner_element{
width:550px;
float:right;
}
However, you may have noticed that the container height, and thus background color, div does not [...]]]></description>
			<content:encoded><![CDATA[<p>You may be used to using a div container to center-align floated elements. This is a common practice for me&#8211; you set the container width and the right/left margins to auto. See the example below:</p>
<p><strong>XHTML Markup</strong></p>
<p style="padding-left: 30px;">&lt;div id=&#8221;container&#8221;&gt;</p>
<p style="padding-left: 60px;">&lt;div id<strong>=&#8221;</strong>floated_left_inner_element&#8221;&gt;&lt;/div&gt;</p>
<p style="padding-left: 60px;">&lt;div id=&#8221;floated_right_inner_element&#8221;&gt;&lt;/div&gt;</p>
<p style="padding-left: 30px;">&lt;/div&gt;</p>
<div id="container">
<p><strong>CSS</strong></p>
<p>#container {<br />
width:900px;<br />
margin-right:auto;<br />
margin-left:auto;<br />
background-color:#CCCCCC;<br />
}</p>
<p>#floated_left_inner_element{<br />
width:350px;<br />
float:left;<br />
}</p>
<p>#floated_right_inner_element{<br />
width:550px;<br />
float:right;<br />
}</p>
<p>However, you may have noticed that the container height, and thus background color, div does not expand with the height of it&#8217;s inner elements. This was very frustrating to me for a while and I often tied to use JavaScript to correct this issue. But thankfully, the CSS answer I much more simple and efficient.</p>
<p>Thanks to a post by <a href="http://matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks">Matthew James Taylor</a>, I now know the golden rule:</p>
<p><em><strong> A floated container div will always be the height of it&#8217;s floated contents.</strong></em></p>
<p>Therefore, you set the container to float left or (right). But then your content is not centered, which was the point of the container after all. To fix this, you simply add another outer container around the first container. See code below:</p>
<p><strong>XHTML Markup</strong></p>
<p style="padding-left: 30px;">&lt;div id=&#8221;outer_container&#8221;&gt;<strong><br />
</strong></p>
<p style="padding-left: 60px;">&lt;div id=&#8221;container&#8221;&gt;</p>
<p style="padding-left: 90px;">&lt;div id<strong>=&#8221;</strong>floated_left_inner_element&#8221;&gt;&lt;/div&gt;</p>
<p style="padding-left: 90px;">&lt;div id=&#8221;floated_right_inner_element&#8221;&gt;&lt;/div&gt;</p>
<p style="padding-left: 60px;">&lt;/div&gt;</p>
<p style="padding-left: 30px;">&lt;/div&gt;</p>
<p><strong>CSS</strong></p>
<p>#outer_container {<br />
width:900px;<br />
margin-right:auto;<br />
margin-left:auto;<br />
}</p>
<p>#container {<br />
width:900px;<br />
float:left;<br />
background-color:#CCCCCC;<br />
}</p>
<p>#floated_left_inner_element{<br />
width:350px;<br />
float:left;<br />
}</p>
<p>#floated_right_inner_element{<br />
width:550px;<br />
float:right;<br />
}</p>
<p><strong>Voila, magic =]</strong></div>
]]></content:encoded>
			<wfw:commentRss>http://www.luxewebmedia.com/2010/07/08/css-floated-div-elements-and-container-height/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
