Created
March 11, 2018 22:27
-
-
Save 3on/17d9e357362d6f37711e0b24970b4f64 to your computer and use it in GitHub Desktop.
CSS float and clearfix || https://jsbin.com/niturag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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