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 8809391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:51:54+00:00 2026-06-14T02:51:54+00:00

This question has been asked a million times but I can’t seem to find

  • 0

This question has been asked a million times but I can’t seem to find the solution for my specific version. Here is what I have:

<div>
    <div id="div1"></div>
    <div id="div2"></div>
    <div id="div3"></div>
</div>

div1 and div2 are always shown and div3 is only sometimes shown. div2 and div3 have fixed widths. I want div1 to fill the remaining space that div2 and possible div3 are not taking up. I want them to appear in the above order left to right ([div1][div2][div3]).

Can anyone help with this?

  • 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-14T02:51:56+00:00Added an answer on June 14, 2026 at 2:51 am

    Answer:

    See in action: http://jsfiddle.net/C9Q3F/3/

    <style>
        div { height:100px; }
        #div1 { background-color:red; }
        #div2 { background-color:blue; width:75px; float:right; }
        #div3 { background-color:green; width:100px; float:right; }
    </style>
    ​
    <div>
        <div id="div2"></div>
        <div id="div3"></div>
        <div id="div1"></div>
    </div>​
    

    Explanation:

    The reason this works, is – the order of the divs changed – so it writes div2 and div3 to the page, both with fixed widths, and both floating. So by the time div1 is written (now last), it’s default 100% width will fill the 100% of the available width. Since the other divs are taking up their space already, the “available width” is what’s left.

    For other cases (eg. last div fills space):

    If you want the last div to fill the remaining space instead of the first, like this question/answer, just tweak it to use float:left; instead of float:right; and change the div order and widths – same concept as this and works just fine.

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

Sidebar

Related Questions

This question has been asked before...but I can't seem to find the exact answer
I know this has been asked a million times but i can't seem to
This question has been asked before perhaps multiple times, but I can't get the
This question has been asked many times, but I tried every solution and none
This question has been asked many times before, but they all seem to relate
I know this question has been asked million times, but I'm not able to
I know it seems like this question has been asked a million times, but
This question must have been asked million times already, but i just couldn't find
Hey all, I know this question has been asked a million times before but
I know this has been asked a million times before but i still can't

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.