Skip to content

Instantly share code, notes, and snippets.

@lessmost
Last active September 11, 2015 06:52
Show Gist options
  • Save lessmost/98efd7450edfcac974e6 to your computer and use it in GitHub Desktop.
Save lessmost/98efd7450edfcac974e6 to your computer and use it in GitHub Desktop.
Oyyxgr
<h2>Using BFC to contains float elements</h2>
<p>This can also used to clear the float (clearfix)
</p>
<p>
Another better way is using clearfix class
</p>
<div class="container">
<div class="box">
<p>Sibling</p>
</div>
<div class="box">
<p>Sibling</p>
</div>
</div>
<div class="main">
<p>Block</p>
</div>
* {
box-sizing: border-box;
}
body {
text-align: center;
}
.container {
background-color: green;
overflow: hidden;
padding: 5px;
}
.box {
float: left;
margin: 0 20px;
width: calc(50% - 40px);
background-color: lightgreen;
}
.main {
background-color: yellow;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment