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

  • Home
  • SEARCH
  • 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 9257851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:15:13+00:00 2026-06-18T12:15:13+00:00

I have a varying width div. Inside are two others, one is fixed width,

  • 0

I have a varying width div. Inside are two others, one is fixed width, the other is supposed to fill the rest of the area. But I can’t get it to always fill. Depending on the width of the outer-box, it is either too small, or is too big and drops below inner-box-1. How do I get inner-box-2 to fill the rest of outer-box?

http://jsfiddle.net/Y57YP/

HTML

<div id ="outer-box">
   <div id="inner-box-1"></div>
   <div id="inner-box-2"></div>
</div>

CSS

#outer-box{
  width:50%;
  background:#fcc;
  position: relative;
  overflow: auto;
}
#inner-box-1{
  height:50px;
  width:50px;
  background:#ccc;
  float:left;
}
#inner-box-2{
  height:50px;
  width:80%;
  background:#555;
  float:left;
}
  • 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-18T12:15:14+00:00Added an answer on June 18, 2026 at 12:15 pm

    This is one of those odd answers that is easy but totally non-intuitive. You need to trigger block formatting context by using the overflow property in conjunction with the float property.

    See this jsFiddle example.

    #inner-box-2{
       height:50px;
       background:#555;
       overflow:auto;
    }
    

    All I did was remove the width and float from your #inner-box-2 div and add an overflow:auto

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a varying number of <div> s inside a container <div> , that
As the title explains, I have one container div, containing two floating divs of
I need the following in a header of fixed width: A div of varying
I have a (horizontally) centered outer div containing two elements of unknown width: <div
I have a div with two nested divs. The first child has varying height
I have a list inside a div with text of varying lengths. How do
I have a Border inside a Canvas. The Border's height/width are varying according to
I have 4 divs in a fixed width layout: a, b, c, and d,
I have several fixed position divs with the same class at varying distances from
I have a <div> in my page which contains a <table> of varying number

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.