1

I have a very wide table inside a div, which in turn is inside a fieldset which is inside a form which is inside an article.

This wide table results in the div and the fieldset to increase their width. The form does not increase the width.

I want to show a horizontal scrollbar for the div. But this doesn't work, because it has the same width as the table.

How can I prevent the div from increasing its width?
Please know that the height of the table is dynamic and changes based on user interactions.
I would like to achieve this without JS.

Fiddle demonstrating my problem.

If you think this is a duplicate to an existing question, please test the solution first with my specific setup, thanks. I tested quite a few and none seemed to work in my scenario.

Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443

1 Answers1

2

With a deeper look, I noticed that the fieldset element has a min-width attribute inherited directly from the web-kit (at least in Chrome). It appears that it goes against what you want to do.

You can solve your issue by specifying for the fieldset element:

CSS

fieldset { min-width:0px; }

Check this FIDDLE


UPDATE: A fix that also works for Firefox

From an explanation of the fieldset behaviour here (thanks @Pangloss for catching this!):

CSS

fieldset {
    min-width: 0px;
}

@-moz-document url-prefix() {
    fieldset {
        display: table-cell;
    }
}

New FIDDLE

Community
  • 1
  • 1
Frederik.L
  • 5,522
  • 2
  • 29
  • 41