0

I know that most use overflow: auto in this scenario. However, my table width slightly exceeds the content within it (by design, various sections on the page have the same width).

Is there another way I can conditionally hide/show a scrollbar, dependent on the browser width in pixels, perhaps?

My issue is I have a scrollbar popping up too early. Look at this for example:
enter image description here

This is the end of the table, but the scrollbar unnecessarily pops up. This is mostly because of that extra whitespace outside the word "Disconnect". It is calculating the overflow property based on that entire cell. Ideally, I'd like to be able to hide the scrollbar until absolutely needed (e.g. the page becomes sufficiently small such that disconnect starts to get hidden).

If not using overflow: auto, do I have any other options here?

1 Answer 1

2

You're probably trying to solve wrong issue - if the "scrollbar" pops up "unnecessarily" it means you have problem with padding/margin - you should inspect items and see what is overflowing the view - replacing padding with margin or adding box-sizing: border-box might help.

Other than than you can use media queries for your original question:

.element {
    overflow: visible;
}

@media (min-width: 900px) {
    .element {
        overflow: auto;
    }    
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.