Q:
How to fix the issue of CSS collapsing parent having floating children
belongs to collection: HTML / CSS Frequently Asked Questions
HTML / CSS Frequently Asked Questions
- How to write comments in HTML
- How to write comments in CSS
- How to align text vertically center in a DIV element using CSS
- How to remove dotted line around the links or linked images using CSS
- How to set the height of a div to 100% using CSS
- How to align a DIV horizontally center using CSS
- How to change the opacity of an element\'s background without affecting the child elements or text content
- How to define or create style sheet only for Internet Explorer
- How to show and hide dropdown menu on mouse hover using CSS
- How to remove the extra white space underneath an image using CSS
- What is the maximum length of title and meta description tag in HTML for SEO
- How to highlight the background of alternate table row using CSS
- How to fix the issue of CSS collapsing parent having floating children
- How to create custom cursor using CSS
- How to apply shadow effect on elements using CSS
- How to apply shadow effect on text using CSS
- How to disable spell checking from Input Box and Textarea in HTML forms
- How to create drop caps effect using CSS
- How to center align absolute positioned div using CSS
- How to apply border to an element on mouse hover without affecting the layout in CSS
- How to apply CSS opacity in IE7 and IE8 browsers
- How to create 3D flipping effect on mouse hover using CSS
- How to animate text color on mouse hover using CSS
- How to animate background-color of an element on mouse hover using CSS
- How to transform image size on mouse hover without affecting the layout in CSS
- How to make a div element editable in HTML
- How to disable resizable property of text area using CSS
- How to expand select box to its default width on focus using CSS
- How to change the default text selection color in the browsers using CSS
- How to remove the space between inline-block elements in CSS
- How to disable text selection highlighting in the browsers using CSS
- How to change input field or textarea placeholder text color using CSS
- How to truncate long string with ellipsis using CSS
- How to create triangle or caret icons using CSS
- How to remove outline around text input boxes in chrome using CSS
- How to apply multiple background images to an element using CSS
- How to create fixed header or footer using CSS
- How to create two div elements with same height side by side in CSS
- How to set table cellpadding and cellspacing in CSS
- How to remove cell spacing from tables using CSS
- How to place border inside of a div element using CSS
- How to change image on hover with CSS
- How to position text over an image using CSS
- How to create an HTML button that acts like a link
- How to Create a Vertical Line in HTML
- How to Change the Cursor into a Hand Pointer on Hover using CSS
- How to Make a DIV Not Larger than its Contents using CSS
- How to Change the Color of an hr Element using CSS
- How to Auto-resize an Image to Fit into a DIV Container using CSS
- How to Overlay One DIV Over Another DIV using CSS
- How to Stretch and Scale an Image in the Background with CSS
- How to Disable a Link using Only CSS
- How to Vertically Align an Image inside a DIV using CSS
- How to Align Content of a DIV to the Bottom Using CSS
- How to Make a Placeholder for a Select Box in HTML
- How to Hide the Scrollbar on an HTML Page
- How to Make a DIV Vertically Scrollable Using CSS
- How to Right Align Flex Item Using CSS
- How to Center a DIV Horizontally and Vertically Using Flexbox in CSS
- How to Remove Border from IFrame in HTML
- How to Reset or Remove CSS Style for a Particular Element
- How to Set Fixed Width for td Regardless of its Content
- How to Remove Underline from Link in HTML
- How to Make body to Have 100% of the Browser Height
- How to Set Space Between Flex Items Using CSS
Use the CSS
clear
propertyWhen float property applied to the element inside the non floated parent, the parent element doesn't stretch up automatically to accommodate the floated elements. This behavior is typically known as collapsing parent. This is not always obvious if you do not apply some visual properties like background or borders to the parent elements, but it is important to be aware of and must dealt with to prevent strange layout and cross-browser problems.
The CSS
need an explanation for this answer? contact us directly to get an explanation for this answer:after
pseudo-element
in conjunction with thecontent
property is used to resolve the collapsing parent issues in the browsers like Firefox, Chrome, Safari, etc.