<?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>Vjeux &#187; CSS</title>
	<atom:link href="http://blog.vjeux.com/category/css/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.vjeux.com</link>
	<description>French Web Developer</description>
	<lastBuildDate>Mon, 30 Jan 2012 13:31:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Diablofans Theme Improvement</title>
		<link>http://blog.vjeux.com/2011/project/diablofans-theme-improvement.html</link>
		<comments>http://blog.vjeux.com/2011/project/diablofans-theme-improvement.html#comments</comments>
		<pubDate>Thu, 10 Nov 2011 09:17:32 +0000</pubDate>
		<dc:creator>vjeux</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Project]]></category>

		<guid isPermaLink="false">http://blog.vjeux.com/?p=2689</guid>
		<description><![CDATA[Diablofans.com needed a bit of love. It is really gratifying to be able to visually improve a website by an order of magnitude just by changing some colors and fixing broken layout Here are some of the changes I made: Post Poll Blizzquote]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.diablofans.com/">Diablofans.com</a> needed a bit of love. It is really gratifying to be able to visually improve a website by an order of magnitude just by changing some colors and fixing broken layout <img src='http://blog.vjeux.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Here are some of the changes I made:</p>
<table>
<tr>
<td>
<h3>Post</h3>
</td>
</tr>
<tr>
<td style="text-align: center;"><a href="http://blog.vjeux.com/wp-content/uploads/2011/11/diablofans_new.jpg"><img src="http://blog.vjeux.com/wp-content/uploads/2011/11/post_new.png" alt="" /></a></td>
<td style="text-align: center;"><a href="http://blog.vjeux.com/wp-content/uploads/2011/11/diablofans_old.jpg"><img src="http://blog.vjeux.com/wp-content/uploads/2011/11/post_old.png" alt="" /></a></td>
</tr>
<tr>
<td>
<h3>Poll</h3>
</td>
</tr>
<tr>
<td style="text-align: center;"><img src="http://blog.vjeux.com/wp-content/uploads/2011/11/poll_new.png" alt="" /></td>
<td style="text-align: center;"><img src="http://blog.vjeux.com/wp-content/uploads/2011/11/poll_old.png" alt="" /></td>
</tr>
<tr>
<td>
<h3>Blizzquote</h3>
</td>
</tr>
<tr>
<td>
<div style="width: 330px; overflow: hidden;">
  <a href="http://blog.vjeux.com/wp-content/uploads/2011/11/blizzquote_new.png"><img src="http://blog.vjeux.com/wp-content/uploads/2011/11/blizzquote_new.png" alt="" /></a></div>
</td>
<td>
<div style="width: 330px; overflow: hidden;">
  <a href="http://blog.vjeux.com/wp-content/uploads/2011/11/blizzquote_old.png"><img src="http://blog.vjeux.com/wp-content/uploads/2011/11/blizzquote_old.png" alt="" /></a></div>
</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://blog.vjeux.com/2011/project/diablofans-theme-improvement.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WoW Interface Anchor Positioning</title>
		<link>http://blog.vjeux.com/2011/javascript/wow-interface-anchor-positioning.html</link>
		<comments>http://blog.vjeux.com/2011/javascript/wow-interface-anchor-positioning.html#comments</comments>
		<pubDate>Sat, 17 Sep 2011 20:41:31 +0000</pubDate>
		<dc:creator>vjeux</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://blog.vjeux.com/?p=2308</guid>
		<description><![CDATA[I've always found CSS positioning with both float and position: absolute/relative hard to work with. I want to introduce to you an alternative way borrowed from the World of Warcraft Interface: Anchors. Anchor The concept is extremely simple. You can tell where you want the element to be, relative to another. For example, top left [...]]]></description>
			<content:encoded><![CDATA[<p>I've always found CSS positioning with both <code>float</code> and <code>position: absolute/relative</code> hard to work with. I want to introduce to you an alternative way borrowed from the World of Warcraft Interface: Anchors.</p>
<h3>Anchor</h3>
<p>The concept is extremely simple. You can tell where you want the element to be, relative to another. For example, <code>top left</code> of this blog's main content is <code>10px right</code> relative to the <code>top right</code> of the menu.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;frame</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Content&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;anchor</span> <span style="color: #000066;">point</span>=<span style="color: #ff0000;">&quot;TOP LEFT&quot;</span> <span style="color: #000066;">relativeTo</span>=<span style="color: #ff0000;">&quot;Menu&quot;</span> <span style="color: #000066;">relativePoint</span>=<span style="color: #ff0000;">&quot;TOP RIGHT&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/frame<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<ul>
<li>Allowed points: <code><br />&nbsp;&nbsp;&nbsp;TOP&nbsp;LEFT&nbsp;,&nbsp;&nbsp;TOP&nbsp;&nbsp;&nbsp;,&nbsp;TOP&nbsp;RIGHT<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LEFT&nbsp;,&nbsp;CENTER&nbsp;,&nbsp;RIGHT<br />
BOTTOM&nbsp;LEFT&nbsp;,&nbsp;BOTTOM&nbsp;,&nbsp;BOTTOM&nbsp;RIGHT</code></li>
<li>Default Values:
<ul>
<li><strong><code>point, relativePoint</code></strong>: <code>TOP LEFT</code>.</li>
<li><strong><code>relativeTo</code></strong>: Parent of the element.</li>
<li><strong><code>x</code></strong>, <strong><code>y</code></strong>: 0.</li>
</ul>
</li>
</ul>
<h3>Demo</h3>
<p>I've made a quick implementation of this behavior in HTML using <code>data-attribute</code>. Check the Javascript tab to see the 35 lines of CoffeeScript that makes the following code work:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- In order to put the sidebar centered at the right of the frame:</span>
<span style="color: #808080; font-style: italic;">  Sidebar.left = Frame.right                                          --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;sidebar&quot;</span> <span style="color: #000066;">data-anchor</span>=<span style="color: #ff0000;">&quot;left, #frame, right&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- In order to put the chat at the top right of the screen:</span>
<span style="color: #808080; font-style: italic;">  Chat.topRight = HTML.topRight + {x: -10, y: 10}                       --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;chat&quot;</span> <span style="color: #000066;">data-anchor</span>=<span style="color: #ff0000;">&quot;top right, html, top right, -10, 10&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><iframe style="width: 100%; height: 300px" src="http://jsfiddle.net/EPXQt/5/embedded/result,js,html,css/"></iframe></p>
<h3>Limitations</h3>
<h4>Static</h4>
<p>The current code works well for static elements. As there <a href="http://stackoverflow.com/questions/3444719/how-to-know-when-an-dom-element-moves-or-is-resized">isn't any event for DOM move/resize</a>, the position will not be updated if anything moves <img src='http://blog.vjeux.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>It might be possible to achieve the same effect by setting properly the <code>position: absolute/relative</code> and <code>top/bottom/right/left</code> CSS properties. I'd be really interested to know if you try to tackle this challenge <img src='http://blog.vjeux.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h4>CSS Attribute</h4>
<p>It would be more semantically correct to add an <code>anchor</code> CSS attribute instead of an HTML data attribute. However, <a href="http://stackoverflow.com/questions/2926326/can-i-access-the-value-of-invalid-custom-css-properties-from-javascript">it's not possible to access the value of a custom CSS property</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#sidebar</span> <span style="color: #00AA00;">&#123;</span>
  anchor<span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">bottom</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #cc00cc;">#frame</span> <span style="color: #000000; font-weight: bold;">top</span> <span style="color: #000000; font-weight: bold;">right</span> <span style="color: #933;">10px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h4>Multiple Anchors</h4>
<p>World of Warcraft supports multiple anchors. For example if you anchor both the left and right sides, then the width of the element is going to be updated accordingly.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vjeux.com/2011/javascript/wow-interface-anchor-positioning.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>CSS: One Line Justify</title>
		<link>http://blog.vjeux.com/2011/css/css-one-line-justify.html</link>
		<comments>http://blog.vjeux.com/2011/css/css-one-line-justify.html#comments</comments>
		<pubDate>Wed, 14 Sep 2011 09:24:03 +0000</pubDate>
		<dc:creator>vjeux</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://blog.vjeux.com/?p=2262</guid>
		<description><![CDATA[I came across a CSS problem, text-align: justify does not work with only one line. Justify behavior The reason is because it has been designed with paragraphs in mind. It justifies all the lines but the last one. Normal Justify Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore [...]]]></description>
			<content:encoded><![CDATA[<p>I came across a CSS problem, <code>text-align: justify</code> does not work with only one line.</p>
<h3>Justify behavior</h3>
<p>The reason is because it has been designed with paragraphs in mind. It justifies all the lines but the last one.</p>
<table width="100%" style="text-align: center;">
<tr>
<td width="50%">
Normal Justify
<p style="text-align: justify; border: 1px solid #999; padding: 3px; margin: 3px;">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat laboris.</p>
</td>
<td width="50%">
Full Justify
<p style="text-align: justify; border: 1px solid #999; padding: 3px; margin: 3px;" class="oneline">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat laboris.</p>
</td>
</tr>
</table>
<style>
.oneline {
  text-align: justify;
}
.oneline:after
{
  content:"";
  display:inline-block;
  width:100%;
}
</style>
<h3>Solution</h3>
<p>The solution (given by <a href="http://webdesign.about.com/b/2008/03/21/reader-question-how-to-justify-a-1-line-headline.htm#comment-266508">cam</a>) is to put an extra tag at the end of the paragraph that will be big enough to create a new line. Fortunately, it is possible to do it without affecting the markup using <code>:after</code>. We are going to put an empty tag as big as the line.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.fulljustify</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">justify</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.fulljustify</span><span style="color: #3333ff;">:after </span><span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">content</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> inline-<span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Now you can add <code>class="fulljustify"</code> in order to justify your one-line divs <img src='http://blog.vjeux.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="oneline" style="width: 400px; border: 1px solid #999; font-size: 20px; margin-left: auto; margin-right: auto;">This is a one-liner. Please justify!</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.vjeux.com/2011/css/css-one-line-justify.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CSS &#8211; Float Techniques</title>
		<link>http://blog.vjeux.com/2010/css/float-techniques.html</link>
		<comments>http://blog.vjeux.com/2010/css/float-techniques.html#comments</comments>
		<pubDate>Sat, 09 Jan 2010 18:14:29 +0000</pubDate>
		<dc:creator>vjeux</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://blog.vjeux.com/?p=792</guid>
		<description><![CDATA[CSS development is a hard land where you have to struggle with many browser incompatibilities and not so easy to use structures. Here are two extremely useful techniques that allow you to get around common float problems. List of items without floats Problem It is common to display a list of items that flow horizontally. [...]]]></description>
			<content:encoded><![CDATA[<p>CSS development is a hard land where you have to struggle with many browser incompatibilities and not so easy to use structures. Here are two extremely useful techniques that allow you to get around common float problems.</p>
<h3>List of items without floats</h3>
<h4>Problem</h4>
<p>It is common to display a list of items that flow horizontally. Common examples are tabs or cloud tags. A common way to write it is to use the float property.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  li { float: left; }
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ul<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>One<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Two<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Three<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ul<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>However, you are going to struggle with the way floating elements flow in the document. You have to clear them, you will have strange behaviors with multiple floats ...</p>
<h4>Technique</h4>
<p>There is a better way to do it: <code>display: inline-block;</code>. The element will behave inline (as a span) when being positioned in the flow and as a block when styling it. Exactly what you want.</p>
<p>The code is nearly the same, but the float is now gone!</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  li { display: inline-block; }
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ul<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>One<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Two<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Three<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ul<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>However, this code does not work in ie7 (and of course ie6). But ... There is a simple trick to make it work! Every time you do a <code>display: inline-block</code>, just add the two associated lines. The magic is explained by <a href="http://blog.mozilla.com/webdev/2009/02/20/cross-browser-inline-block/">Ryan Doherty</a> from Mozilla.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">li <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> inline-<span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
<span style="color: #808080; font-style: italic;">/* The following 2 lines do the magic */</span>
  zoom<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
  <span style="color: #00AA00;">*</span><span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>You can read more about the zoom property and its strangeness on the <a href="http://www.satzansatz.de/cssd/onhavinglayout.html">On Having Layout</a> article.</p>
<h4>Benefits</h4>
<ul>
<li>No more floats and all the problems involved</li>
<li>Cross browser (even ie6)</li>
<li>You can now center elements using <code>text-align</code></li>
</ul>
<h4>Demo</h4>
<style>
.demo-inline {
  text-align: center;
  background-color: #ccc;
  margin: 0 !important;
  padding: 0 !important;
}
.demo-inline li {
  display: inline-block;
  zoom: 1;
  *display: inline;
  border: 1px solid red;
  margin: 5px;
  padding: 5px;
  width: 50px;
  height: 50px;
}
</style>
<div style="width: 300px; margin-top: 10px;">
<ul class="demo-inline">
<li>One</li>
<li>Two</li>
<li>Three</li>
<li>Four</li>
<li>Five</li>
</ul>
</div>
<h3>No more <code>clear</code> to get around floating elements</h3>
<h4>Problem</h4>
<p>When working with floating elements, you are probably going to do something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;float: left;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Left Menu<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;float: left;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Another Menu<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;float: right;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Content<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;br</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;clear: both;&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The problem is you have to use a <code>&lt;br /&gt;</code> which takes vertical space, completely destroy your padding/margin organization ...</p>
<h4>Technique</h4>
<p>There is one <a href="http://www.quirksmode.org/css/clearing.html">easy technique</a> described by PPK that is solving all the problems and has no side effect!</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;width: 100%; overflow: auto;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;float: left;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Left Menu<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;float: left;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Another Menu<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;float: right;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Content<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The trick is to add <code>width: 100%; overflow: auto;</code> to the parent box and it just works! The parent box now wraps around all the floating elements and you can properly style it. It works will all browsers, even with ie6.</p>
<h4>Demo</h4>
<div style="width: 300px; margin-top: 10px; margin-bottom: 20px;">
<div style="width: 100%; overflow: auto; border: 1px solid red; padding: 0; margin: 0;">
<div style="float: right; background-color: orange; height: 160px; width: 80px;"></div>
<div style="float: left; background-color: green; height: 80px; width: 200px;"></div>
<div style="float: left; background-color: blue; height: 40px; width: 150px;"></div>
</p></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.vjeux.com/2010/css/float-techniques.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

