Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Parent does not expand when child floats left

Featured Replies

Hey,

 

I have been experiencing this issue for a number of years and have never actually my desirable way around it, so thought I'd ask and see if anyone has any clues.

 

Basically if I have a div that has a contained div that floats to the left, then the parent will not stretch to the height of the floated div.

 

For example if I did something along these lines:

 

<div style="background-color: #000000;">
<div style="float: left;">
<p>put a bunch of content here</p>
</div>
</div>

 

The background should be black behind all the content of the contained div, but instead it would not resize the div to the height of the contained one.

 

Anyone experienced this before and found a way around it that does not involve explicitly declaring the height of the parent?

Just add overflow:auto to the CSS for the parent and it will expand to accommodate floated elements. :)

  • Author

As simple as that!? Much appreciated :) thanks!

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.