Reputation: 5914
I want to center a fieldset but I want it to be resize due to its content, so I added the attr display: inline-block;
to the style, which makes that, but it moves the fieldset to the left...
I was using margin: 0 auto;
to center the fieldset but its not working anymore...
Upvotes: 1
Views: 4323
Reputation: 253318
If you just add text-align: center;
to your fieldset
CSS rules, it seems to work (centering the label
s against the input
s below).
As it's the fieldset
that needs to be centred, rather than its content, simply add the text-align: center;
to the parent element of the fieldset
. Normally this should be the form
element (or a parent fieldset
, since nesting is valid), but as there is no form
in the linked example I've applied the text-align
to the body
element: updated JS Fiddle demo.
Upvotes: 3