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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:03:44+00:00 2026-05-16T17:03:44+00:00

I have a variable number of divs acting as columns, and I would like

  • 0

I have a variable number of divs acting as columns, and I would like a variable number of them to have static widths (in pixels) and a variable number of them to expand to the remaining width in the window. If I make the fluid column widths combine to 100%, some columns will be squeezed out of the row – do I need to use javascript to substract the widths of the static columns to determine the fluid columns’ share of the window width, or is there a css attribute that I can use?

By variable, I mean I don’t know in advanced how many fluid or static columns there are, so I can’t use a prebuild 2 or 3 column templates.

Here is an example of what I mean:

<style>
    #ColumnContainer > div { display:inline-block }
</style>

<div id="ColumnContainer">
    <div style="width:200px"></div>
    <div class="FluidColumn"></div>
    <div class="FluidColumn"></div>
    <div style="width:100px"></div>
    <div class="FluidColumn"></div>
</div>

<script>
    /*
        Do i need to do this...

        1. get window width
        2. add the widths of all divs inside #ColumnContainer without the 'FluidColumn' class
        3. subtract the total static width from the window width
        4. divide this remaining width by the number of divs with the 'FluidColumn' class
        5. set the the width, in percentage, for the divs with the 'FluidColumn' class
    */
</script>

<style>
    // Or...

    .FluidColumn { width: ??? } // is there a special width attribute that works this out?
</style>
  • 1 1 Answer
  • 2 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-05-16T17:03:46+00:00Added an answer on May 16, 2026 at 5:03 pm

    The problem is with the word variable, you see. Have a look at this article here: http://www.alistapart.com/articles/holygrail/

    What it describes is the case for two fixed width and one width columns. Given this, you should be able to create a layout with as many fixed and variable width columns as you want.

    However, there are always limitations, and if you use too many columns the stylesheet can get messy. Why don’t you explain in greater details what variable here means strictly, so that we can help you better?


    Edit

    In your case, the answer is certainly no, you have to use Javascript. There are other possibilities, like generating the styles dynamically on the server-side, or using display: table, but I would recommend against any of these. They are incredibly troublesome, and difficult to maintain. Using Javascript here also gives you more flexibility in determining the ratio and widths of the fluid columns.

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

Sidebar

Related Questions

Suppose I have a variable number of static image resources that I would like
I have a variable number of table rows (n), and I would like the
I have a datagrid with a variable number of columns that I am generating
I have a form that has 8 columns and a variable number of rows
Using jQuery 1.6.2 I have a variable number of floated divs inside a parent.
I have a variable number of boxes and I'd like to display as many
I have a parent div with a variable number of equally sized child divs
I have a container div listings_container that contains a variable number of divs listing
How I can have variable number of parameters in my function in C++. Analog
I have a variable number of points on a canvas. Sometime its four other

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.