Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8048851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:36:46+00:00 2026-06-05T06:36:46+00:00

I have a div wrapped around two children, one floated left and the other

  • 0

I have a div wrapped around two children, one floated left and the other right. I want to put a border and background around the children, but the div has 0 height since it doesn’t resize to fit the children.

Here is an example of it in action:
http://jsfiddle.net/VVZ7j/17/

I want the red background to go all the way down. I’ve tried height:auto, but that didn’t work.

Any and all help would be appreciated, thanks.

P.S. I don’t want to use any javascript if that’s possible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:36:48+00:00Added an answer on June 5, 2026 at 6:36 am

    This is a common issue when working with floats. There are several common solutions, which I have ordered by personal preference (best approach first):

    1. Use the ::after CSS pseudo element. This is know as the ‘clearfix’, and works IE8 and up. If you need compatibility with earlier versions of IE, this answer should help. Example.

      .parentelement::after {
          content: "";
          display: table;
          clear: both;
      }
      
    2. Add the two floats into a container with the CSS attribute overflow: auto or overflow: hidden. However, this approach can cause issues (e.g. when a tooltip overlaps the edges of the parent element a scrollbar will appear). Example.

      <div style="overflow: auto">
          <div style="float: left"></div>
          <div style="float: left"></div>
      </div>
      
    3. Add a set height to the parent element. Example.

      <div style="height: 200px">
          <div style="float: left"></div>
          <div style="float: left"></div>
      </div>
      
    4. Make the parent element a float. Example.

      <div style="float: left">
          <div style="float: left"></div>
          <div style="float: left"></div>
      </div>
      
    5. Add a div after the floats with clear: both. Example.

      <div style="float: left"></div>
      <div style="float: left"></div>
      <div style="clear: both"></div>
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a div wrapped around an image, like this: <div class=containing-div> <div class=image-wrapper>
If I have an image with a div wrapped around it, how do I
I have a div that is wrapped in a few other divs that are
I have two divs and a wrapper div around them. The wrapper div is
I have a div wrapped around a couple span 's and using JS to
I have some images that are wrapped within containers like this: <div id=swatchcontainer> <div
I have a div.xx-wrapper:hover in CSS which when hovered on, I want to call
I have a set of 28 links in a wrapper div element. Each one
I have DIV element which only has a few lines in and a background
I have a list of links to the left and a fixed div with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.