Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i make a fieldset `display: block; overflow: auto` show a scrollbar?

Tags:

html

css

I want my <fieldset> elements to behave like vanilla <div>'s by filling their containing element and showing a scrollbar when they are set to overflow: auto.

For instance, I don't see why the fieldset in this example is wider than its containing div:

<div class=outer>
  <fieldset class=inner>
      fooooooooooooooooooooooooooooooooooooo
  </fieldset>
</div>

<div class=outer>
  <div class=inner>
    fooooooooooooooooooooooooooooooooooooooo
  </div>
</div>

and corresponding css:

.outer {
  width: 60px;
}

.inner {
  overflow: auto;
  display: block;
  height: 60px;
  border: 1px solid red;
}
like image 721
aaronstacy Avatar asked Jan 13 '23 22:01

aaronstacy


1 Answers

It turns out the culprit (in some cases) was the user-agent stylesheet in webkit was setting:

fieldset {
  min-width: -webkit-min-content;
}

setting min-width: 0; in the stylesheet corrected the issue in Chrome 27, Safari 6.0.2, and WebKit Nightly r146031. It fails to correct the issue in Chrome 25 and FireFox 19.0.2.

Either way this does not solve the problem.

like image 144
aaronstacy Avatar answered Jan 19 '23 12:01

aaronstacy