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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:51:43+00:00 2026-06-09T01:51:43+00:00

I have two divs, once for main page content and the other for a

  • 0

I have two divs, once for main page content and the other for a sidebar.

Both have widths set as percentages, so they will keep their proportions if the window is resized. However, the sidebar has a minimum width, since that content can only resize so much before it begins to look broken. When the window is resized small enough that the min-width kicks in, the sidebar begins to encroach on the main page content, because the main page content does not know that it now needs to take up a smaller percentage than the one defined to account for the sidebar. I’m trying to make it so that, when we have enough width, the main content and sidebar can maintain their respective proportions, but when we get to the point where the sidebar content would begin to look broken, the main content adjusts its width more to compensate.

Is there a way to do this with css/html, or will I need to write some JavaScript to calculate the new widths and adjust the values in the stylesheet dynamically?

Here’s a (simplified) example of what I have:

HTML:

<div id="maincontent">
    <!-- Main page content here -->
</div>

<div id="sidebar">
    <!-- Sidebar content -->
</div>

CSS:

#maincontent
{
    width: 85%;
}

#sidebar
{
    width: 15%;
    min-width: 120px;
}

In this example, everything will be fine as-is as long as the browser window is more than 800px wide. But once we drop below 800px, the maincontent needs to now become smaller than 85%, to make up for the fact that 120px is more than 15% of the browser width.

  • 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-09T01:51:46+00:00Added an answer on June 9, 2026 at 1:51 am

    You could try

    @media all and ( max-size: 800px )  {
        #maincontent { width: 75%; }
    }
    

    of course, replace 800px and 75% with the screen size and percent that fits

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

Sidebar

Related Questions

I have two divs floated left so that they appear next to each other.
I have two divs, both with position:absolute; , one inside the other. The parent
I have a small page with two divs, clicked on the first div will
I have two divs that are not nested, one below the other. They are
I have two divs sr-left-checks and sr-right-checks. they both contain unordered lists. The left
I have two divs whose widths are controlled by percentages. I want the right
I have two divs one inside another. I have given some border to both
i have two divs one floated to the left and the other to the
I have two divs, one that holds some stuff and the other with all
I have two divs, one inside the other, and i want block the inside

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.