Skip to content

Instantly share code, notes, and snippets.

@maxhoffmann
Created March 9, 2013 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxhoffmann/5125405 to your computer and use it in GitHub Desktop.
Save maxhoffmann/5125405 to your computer and use it in GitHub Desktop.
Clearing floats with overflow: auto
/**
* Clearing floats with overflow: auto
*/
.bg {
background: red;
}
.cf {
overflow: auto;
}
.left {
float: left;
height: 100px;
}
.right {
float: right;
height: 100px;
}
html {
font-family: sans-serif;
}
<h2>You should see a red box if it works:</h2>
<div class="bg cf">
<div class="left"></div>
<div class="right"></div>
</div>
// alert('Hello world!');
{"view":"separate","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment