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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:40:04+00:00 2026-06-02T01:40:04+00:00

I have 3 divs: .main_content, .content_top, .content_bottom .main_content is set to 100% but 100%

  • 0

I have 3 divs:

.main_content, .content_top, .content_bottom

.main_content is set to 100% but 100% is not the size of the browser window, it’s inside the middle of my page.

.content_top is set at 60% height.

I want to set the height of .content_bottom to the rest of the space available inside .main_content via javascript.

For example, if .main_content was 800px high, and .content_top was 600px high, I want to set .content_bottom to 200px.

This is a simplified example, my situation is not as easy as specifying 40% or leaving the browser to decide. For one, there’s currently 46px of padding on .content_top. I’m doing a split screen like interface between .content_top and .content_bottom dragging a bar to resize both. This is mostly working, just having trouble with the bottom portion. Being able to set .content_bottom to a specific height(i.e. 198px) would solve all of my current problems. Happy to elaborate on this example, as well as dig into some actual code, but was hoping there was an easy method for calculating this and was having trouble finding a good example that worked cross-browser, thanks!

  • 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-02T01:40:05+00:00Added an answer on June 2, 2026 at 1:40 am

    Assuming you’re using vanilla JavaScript (and not a library), I’d suggest:

    ​var cBs = ​document.getElementsByClassName('content_bottom');
    
    for (var i=0,len=cBs.length; i<len; i++){
        var p = cBs[i].parentNode;
        cBs[i].style.height = (parseInt(p.offsetHeight,10) - parseInt(p.getElementsByClassName('content_top')[0].offsetHeight,10)) + 'px';
    }​​​​​​​​​​
    

    JS Fiddle demo.

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

Sidebar

Related Questions

I have several DIVs on a page. Inside these DIVs I have several form-elements
I have 3 divs inside a div. I have set CSS to style links
I have two MAIN DIVs inside a DIV which is a PART of the
I have a list which have divs inside it.. Now when i use nested
Say I have the following DIVs: <div id=top>Page header</div> <div id=main>Main content</div> <div id=sidebar>Sidebar
I have 3 divs at the bottom of the page each with a link.
Basically this is my issue, I have a container with 4 divs inside, in
I have 3 divs: a banner at the top of my page (think Facebook,
I have a div that scrolls (the main page does not have scrollbars) and
I have 2 divs inside a container, Each of the inside divs are floated

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.