Skip to content

Commit 6992935

Browse files
thoppenecolas
authored andcommitted
Fix fieldset width in Chrome and Firefox
Fixes an issue in Firefox [1] and Chrome [2]. The implicit width of `fieldset` can be determined by the width of descendants rather than the parent container. This change (adding `min-width:0`) makes the `fieldset` behave like a `div` in this regard. [1] https://bugzilla.mozilla.org/show_bug.cgi?id=504622 [2] http://stackoverflow.com/questions/8084343/google-chrome-fieldset-overflow-bug Close #272
1 parent dafaf9e commit 6992935

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

normalize.css

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,15 @@ figure {
257257
========================================================================== */
258258

259259
/**
260-
* Define consistent border, margin, and padding.
260+
* 1. Define consistent border, margin, and padding.
261+
* 2. Address width being affected by wide descendants in Chrome and Firefox.
261262
*/
262263

263264
fieldset {
264-
border: 1px solid #c0c0c0;
265-
margin: 0 2px;
266-
padding: 0.35em 0.625em 0.75em;
265+
border: 1px solid #c0c0c0; /* 1 */
266+
margin: 0 2px; /* 1 */
267+
min-width: 0; /* 2 */
268+
padding: 0.35em 0.625em 0.75em; /* 1 */
267269
}
268270

269271
/**

test.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,13 @@ <h1>Tabular data</h1>
268268
<h1>Forms</h1>
269269

270270
<form>
271+
<div style="width:500px;">
272+
<fieldset>
273+
<legend>Fieldset with a wider child</legend>
274+
<div style="width:600px; height:50px; background:red;"></div>
275+
</fieldset>
276+
</div>
277+
271278
<fieldset>
272279
<legend>Inputs as descendents of labels (form legend). This doubles up as a long legend that can test word wrapping.</legend>
273280
<p><label>Text input <input type="text" value="default value that goes on and on without stopping or punctuation"></label></p>

0 commit comments

Comments
 (0)