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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:31:43+00:00 2026-06-15T17:31:43+00:00

My CSS looks like this: div.SOMECLASS { position: absolute; max-height: 300px height: auto; width:

  • 0

My CSS looks like this:

div.SOMECLASS {
  position: absolute;
  max-height: 300px
  height: auto;
  width: auto;
  overflow: auto;
  ...
}

The div height and width scale automatically. The height has a fixed maximum though: as soon as this value is reached vertical scrollbars appear. This works all pretty swell.

Now the issue:
When the vertical scrollbar appears, it uses up around 10px of horizontal space, as the scrollbar will be placed inside the div.
However, the width is not autoscaled to allow for these additional 10-something pixels used up by the vertical scrollbars. As the horizontal width before the adding the vertical scrollbars was just exactly right for the content (as expected from the width:auto setting), the div now also displays horizontal scrollbars – to allow for the missing 10 pixels. This is silly.

  • How can I avoid having these horizontal scrollbars and just autoscale the width of the div to make the vertical scrollbars fit?

If possible I am looking for a solution which does not rely on just completely disabling horizontal scrolling, as this will probably be needed at some point (i.e. for certain inputs).

  • 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-15T17:31:44+00:00Added an answer on June 15, 2026 at 5:31 pm

    I found a solution which is working but far from perfect:

    I added a padding-right : 15px to my div, to automatically grow the entire div. Now if the vertical scrollbars appear, they fit within the padding so the horizontal width is still ok.

    Regretfully the padding of course also shows up when no vertical scrolling is needed, making my div just a tiny bit wider than it would have to be… :/ Well, in my eyes this is still preferable to unneeded horizontal scrollbars.

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

Sidebar

Related Questions

I have CSS that looks like this: div#sbar {position:absolute;top: 10px;bottom: 10px;left:10px; right: 10px;} There's
I currently have a div whose css looks like this: .class { overflow:auto; resize:
My CSS looks like this: #menu { width: 1024px; height: 25px; margin: 0 auto;
My CSS rule looks like this: #my-div{ display: none; position: absolute; left: -160px; bottom:
My <style> for thumbnails currently looks like this: <style type=text/css> img.TN { width: 100%;
I have CSS that looks like this... .ColorSeparatorArea { background-color: #3d3d77; height: 1px; }
I have some HTML and CSS that looks like this: <div id=TheContainer> <div class=MyDivs></div>
I have some code in HTML and CSS where HTML looks like this: <div
I have a CSS that looks like this: CSS table { width: 100%; font-family:
My html code looks like this: A wrapper div (percent width, floated left) containing:

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.