Skip to content

Instantly share code, notes, and snippets.

@3on
Created March 11, 2018 22:27
Show Gist options
  • Save 3on/17d9e357362d6f37711e0b24970b4f64 to your computer and use it in GitHub Desktop.
Save 3on/17d9e357362d6f37711e0b24970b4f64 to your computer and use it in GitHub Desktop.
CSS float and clearfix || https://jsbin.com/niturag
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
.parent {
border: 2px solid #888;
/* height: 124px; */ /* DOTH it works */
}
.parent::after {
clear: both;
content: "";
display: block
}
.parent div {
/* float: left; */
/* Or Even better: https://stackoverflow.com/a/8554080/959722 */
display: inline-block;
height: 100px;
width: 100px;
margin: 10px;
border: 2px solid #e46;
}
</style>
</head>
<body>
<div class="parent">
<div></div>
<div></div>
</div>
<script id="jsbin-source-css" type="text/css">.parent {
border: 2px solid #888;
/* height: 124px; */ /* DOTH it works */
}
.parent::after {
clear: both;
content: "";
display: block
}
.parent div {
/* float: left; */
/* Or Even better: https://stackoverflow.com/a/8554080/959722 */
display: inline-block;
height: 100px;
width: 100px;
margin: 10px;
border: 2px solid #e46;
}</script>
</body>
</html>
.parent {
border: 2px solid #888;
/* height: 124px; */ /* DOTH it works */
}
.parent::after {
clear: both;
content: "";
display: block
}
.parent div {
/* float: left; */
/* Or Even better: https://stackoverflow.com/a/8554080/959722 */
display: inline-block;
height: 100px;
width: 100px;
margin: 10px;
border: 2px solid #e46;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment