Skip to content

Instantly share code, notes, and snippets.

@lisacatalano
Last active April 8, 2019 23:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lisacatalano/7109314 to your computer and use it in GitHub Desktop.
Save lisacatalano/7109314 to your computer and use it in GitHub Desktop.
Float Collapsing Parent Solutions
/* Option 0: Set height on parent (only works if parent has a fixed height) */
ul {
height: 43px;
}
/* Option 1: Float the parent */
ul {
float: left;
}
/* Option 2: Add overflow property to the parent */
ul {
overflow: auto;
}
/* Option 3: Add empty div at bottom of parent container with a class "clearfix" */
/* Add to HTML: <div class="clearfix"></div> */
.clearfix {
clear: both;
}
/* Option 4: Add a class of .clearfix to parent element */
.clearfix:after {
content: "";
display: table;
clear: both;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment