8

I have an issue with the width of a fieldset. It's not auto adjusting to it's content. It sets the width to the width of the screen. Is there a way to set it to auto adjust to the width of the content of the fieldset?

user441940
  • 81
  • 1
  • 1
  • 2
  • 4
    dup of http://stackoverflow.com/questions/2302495/is-there-anyway-to-have-a-fieldset-width-only-be-as-wide-as-the-controls-in-them – cofiem Sep 08 '10 at 01:20
  • 2
    The solution didn't work for me. I had to set `fieldset{ min-width: auto; }` as fieldset uses min-width as -webkit-min-content, as mentioned in the following post - https://stackoverflow.com/questions/27660423/fieldset-width-100-of-parent. – Naren Feb 16 '18 at 10:24

5 Answers5

9

A fieldset is as large as the parent container, just like any block-level element, if you do not give it a fixed width. So you have to make it display: inline-block.

Frank van Wijk
  • 3,234
  • 20
  • 41
4

This should work

    <fieldset style="width:0px">

    </fieldset>
David
  • 501
  • 1
  • 7
  • 13
-1

here is an example : http://www.pixy.cz/blogg/clanky/css-fieldsetandlabels.html

Darius
  • 253
  • 1
  • 2
  • 9
-2

Sett the width to 0
Hml:

<fieldset class="field">
</fieldset>

Css:

.field {
    width: 0;
}
Persijn
  • 14,624
  • 3
  • 43
  • 72
-3
<fieldset style="width:270px">