<?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>Latent Motion &#187; float</title>
	<atom:link href="http://www.latentmotion.com/tag/float/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.latentmotion.com</link>
	<description>Usability, Design and Front-Side Programming</description>
	<lastBuildDate>Tue, 27 Jul 2010 05:40:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Div Class Clear &#8211; Without the Markup</title>
		<link>http://www.latentmotion.com/div-class-clear-without-the-markup/</link>
		<comments>http://www.latentmotion.com/div-class-clear-without-the-markup/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 16:00:00 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[background bugs]]></category>
		<category><![CDATA[background fix]]></category>
		<category><![CDATA[background stretching]]></category>
		<category><![CDATA[browser bugs]]></category>
		<category><![CDATA[clear]]></category>
		<category><![CDATA[div class clear]]></category>
		<category><![CDATA[div clear]]></category>
		<category><![CDATA[float]]></category>
		<category><![CDATA[float nearly everything]]></category>

		<guid isPermaLink="false">http://www.latentmotion.com/?p=302</guid>
		<description><![CDATA[The Div Class Clear is an old trick for getting container backgrounds to stretch down to the bottom of its contents. Although there has since been a push for the &#8220;float nearly everything&#8221; technique, I&#8217;m not convinced that constantly setting floats and widths across all elements is a sustainable method. Instead, let&#8217;s address the only [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.positioniseverything.net/easyclearing.html">Div Class Clear</a> is an old trick for getting container backgrounds to stretch down to the bottom of its contents. Although there has since been a push for the &#8220;<a href="http://orderedlist.com/articles/clearing-floats-the-fne-method">float nearly everything</a>&#8221; technique, I&#8217;m not convinced that constantly setting floats and widths across all elements is a sustainable method. Instead, let&#8217;s address the only problem people have with the Div Class Clear method &#8211; the added markup.</p>
<p>We can remove this markup quite simply with jQuery. Rather than mess with the actual on-page elements, why not insert it dynamically? Check out the code:</p>
<pre><pre class="brush: jscript;">
&lt;script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js?ver=1.3.2'&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
    $(document).ready(function(){
$(&quot;*:last-child&quot;).filter(function() {
return $(this).css('float') != 'none';
}).parent().append(&quot;&lt;div class='clear'&gt;&lt;/div&gt;&quot;);
    });
&lt;/script&gt;
&lt;style&gt;
.clear {clear:both;}
&lt;/style&gt;
</pre></pre>
<p>Note: As you may imagine, this method assumes that the viewer has javascript enabled. Given that the downside is a matter of background stretching, and considering all the numerous other things that break when javascript isn&#8217;t enabled, I (generally) readily accept this sacrifice. After all, it&#8217;s not like Flash, where they get no content at all.</p>




	<a rel="nofollow" class="digg" target="_blank" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.latentmotion.com%252Fdiv-class-clear-without-the-markup%252F%26amp%3Btitle%3DDiv%2520Class%2520Clear%2520-%2520Without%2520the%2520Markup%26amp%3Bbodytext%3DThe%2520Div%2520Class%2520Clear%2520is%2520an%2520old%2520trick%2520for%2520getting%2520container%2520backgrounds%2520to%2520stretch%2520down%2520to%2520the%2520bottom%2520of%2520its%2520contents.%2520Although%2520there%2520has%2520since%2520been%2520a%2520push%2520for%2520the%2520%2522float%2520nearly%2520everything%2522%2520technique%252C%2520I%2527m%2520not%2520convinced%2520that%2520constantly%2520setting%2520floats%2520an';" title="Digg"><img src="http://www.latentmotion.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" class="sphinn" target="_blank" href="javascript:window.location='http%3A%2F%2Fsphinn.com%2Findex.php%3Fc%3Dpost%26m%3Dsubmit%26link%3Dhttp%253A%252F%252Fwww.latentmotion.com%252Fdiv-class-clear-without-the-markup%252F';" title="Sphinn"><img src="http://www.latentmotion.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow" class="del.icio.us" target="_blank" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.latentmotion.com%252Fdiv-class-clear-without-the-markup%252F%26amp%3Btitle%3DDiv%2520Class%2520Clear%2520-%2520Without%2520the%2520Markup%26amp%3Bnotes%3DThe%2520Div%2520Class%2520Clear%2520is%2520an%2520old%2520trick%2520for%2520getting%2520container%2520backgrounds%2520to%2520stretch%2520down%2520to%2520the%2520bottom%2520of%2520its%2520contents.%2520Although%2520there%2520has%2520since%2520been%2520a%2520push%2520for%2520the%2520%2522float%2520nearly%2520everything%2522%2520technique%252C%2520I%2527m%2520not%2520convinced%2520that%2520constantly%2520setting%2520floats%2520an';" title="del.icio.us"><img src="http://www.latentmotion.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" class="rss" target="_blank" href="javascript:window.location='http%3A%2F%2Fwww.latentmotion.com%2Ffeed%2F';" title="RSS"><img src="http://www.latentmotion.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow" class="twitter" target="_blank" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DDiv%2520Class%2520Clear%2520-%2520Without%2520the%2520Markup%2520-%2520http%253A%252F%252Fwww.latentmotion.com%252Fdiv-class-clear-without-the-markup%252F';" title="Twitter"><img src="http://www.latentmotion.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.latentmotion.com/div-class-clear-without-the-markup/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
