Skip to content

Commit 3403187

Browse files
committed
Merge pull request #16 from frivoal/florian/box-sizing
Florian/box sizing
2 parents 6113ca6 + 3f7f1ed commit 3403187

File tree

2 files changed

+194
-28
lines changed

2 files changed

+194
-28
lines changed

css-ui/Overview.bs

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ Abstract: This specification describes user interface related selectors,
2222
Deadline: 2012-02-14
2323
Link Defaults: css-color-3 (property) color
2424
Link Defaults: selectors-4 (selector) :indeterminate
25+
Link Defaults: css21 (property) min-width
26+
Link Defaults: css21 (property) min-height
27+
Link Defaults: css21 (property) max-width
28+
Link Defaults: css21 (property) max-height
2529
Ignored Terms: outline-top
2630
Ignored Terms: outline-left
2731
Ignored Terms: nav-index
@@ -125,16 +129,16 @@ border-box
125129
<tr><th>Animatable:</th><td>no</td></tr>
126130
</tbody></table>
127131

128-
<dl>
129-
<dt>content-box</dt>
132+
<dl dfn-type=value dfn-for=box-sizing>
133+
<dt><dfn>content-box</dfn></dt>
130134
<dd>This is the behavior of width and height as specified by CSS2.1.
131135
The specified width and height (and respective min/max properties)
132136
apply to the width and height respectively of the content box of the element.
133137
The padding and border of the element are laid out
134138
and drawn outside the specified width and height.</dd>
135-
<dt>padding-box</dt>
139+
<dt><dfn>padding-box</dfn></dt>
136140
<dd>
137-
The specified width and height (and respective min/max properties)
141+
Length and percentages values for width and height (and respective min/max properties)
138142
on this element determine the padding box of the element.
139143
That is, any padding specified on the element is laid out
140144
and drawn inside this specified width and height.
@@ -146,10 +150,11 @@ As the content width and height
146150
<a href="http://www.w3.org/TR/CSS21/visudet.html#the-width-property">
147151
cannot be negative</a> ([[!CSS21]], section 10.2),
148152
this computation is floored at 0.
153+
Used values, as exposed for instance through {{getComputedStyle()}}, also refer to the padding box.
149154
</dd>
150155
<dt>border-box</dt>
151-
<dd>The specified width and height (and respective min/max properties) on this element
152-
determine the border box of the element.
156+
<dd>Length and percentages values for width and height (and respective min/max properties)
157+
on this element determine the border box of the element.
153158
That is, any padding or border specified on the element
154159
is laid out and drawn inside this specified width and height.
155160
The content width and height are calculated
@@ -159,12 +164,57 @@ and 'height' properties.
159164
As the content width and height
160165
<a href="http://www.w3.org/TR/CSS21/visudet.html#the-width-property">cannot be negative</a> ([[!CSS21]], section 10.2),
161166
this computation is floored at 0.
167+
Used values, as exposed for instance through {{getComputedStyle()}}, also refer to the border box.
162168

163169
Note: This is the behavior of width and height as commonly implemented
164170
by legacy HTML user agents for replaced elements and input elements.
165171
</dd>
166172
</dl>
167173

174+
Note: In contrast to the length and percentage values,
175+
the ''auto'' value of the 'width' and 'height' properties
176+
(as well as other keyword values introduced by later specifications,
177+
unless otherwise specified)
178+
is not influenced by the 'box-sizing' property,
179+
and always sets the size of the content box.
180+
181+
The following terms, whose definitions vary based on the computed value of 'box-sizing' are introduced:
182+
183+
<table border="1">
184+
<tr><th><th>''box-sizing: content-box''<th>''box-sizing: padding-box''<th>''box-sizing: border-box''
185+
<tr><td><dfn>min inner width</dfn><td>'min-width'<td>max(0, 'min-width' &minus; 'padding-left' &minus; 'padding-right')<td>max(0, 'min-width' &minus; 'padding-left' &minus; 'padding-right' &minus; 'border-left-width' &minus; 'border-right-width')
186+
<tr><td><dfn>max inner width</dfn><td>'max-width'<td>max(0, 'max-width' &minus; 'padding-left' &minus; 'padding-right')<td>max(0, 'max-width' &minus; 'padding-left' &minus; 'padding-right' &minus; 'border-left-width' &minus; 'border-right-width')
187+
<tr><td><dfn>min inner height</dfn><td>'min-height'<td>max(0, 'min-height' &minus; 'padding-top' &minus; 'padding-bottom')<td>max(0, 'min-height' &minus; 'padding-top' &minus; 'padding-bottom' &minus; 'border-top-width' &minus; 'border-bottom-width')
188+
<tr><td><dfn>max inner height</dfn><td>'max-height'<td>max(0, 'max-height' &minus; 'padding-top' &minus; 'padding-bottom')<td>max(0, 'max-height' &minus; 'padding-top' &minus; 'padding-bottom' &minus; 'border-top-width' &minus; 'border-bottom-width')
189+
</table>
190+
191+
The <a href="http://www.w3.org/TR/CSS21/visudet.html">Visual formatting model details</a> of [[!CSS21]] are written assuming ''box-sizing: content-box''. The following disambiguations are made to clarify the behavior for all values of 'box-sizing':
192+
193+
<ol>
194+
<li>In <a href="http://www.w3.org/TR/CSS21/visudet.html#blockwidth">10.3.3</a>, the second <q>width</q> in the following phrase is to be interpreted as <a spec="css21">content width</a>: <q>If 'width' is not ''auto'' and 'border-left-width' + 'padding-left' + 'width' + [...]</q>
195+
196+
<li>In <a href="http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-width">10.3.7</a>, <q>width</q> is to be interpreted as <a spec="css21">content width</a> in the following equation: <q>'left' + 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + [...]</q>
197+
198+
<li>In <a href="http://www.w3.org/TR/CSS21/visudet.html#min-max-widths">10.4</a>, <q>width</q>, <q>height</q>, <q>min-width</q>, <q>max-width</q>, <q>min-height</q> and <q>max-height</q> are respectively to be interpreted as <a spec="css21">content width</a>, <a spec="css21">content height</a>, <a>min inner width</a>, <a>max inner width</a>, <a>min inner height</a> and <a>max inner height</a> in the following phrases:
199+
<ol>
200+
<li><q>The tentative used width is calculated [...]</q>
201+
<li><q>If the tentative used width is greater than 'max-width', the rules above are applied again, but this time using the computed value of 'max-width' as the computed value for 'width'.</q>
202+
<li><q>If the resulting width is smaller than 'min-width', the rules above are applied again, but this time using the value of 'min-width' as the computed value for 'width'.</q>
203+
<li><q>Select from the table the resolved height and width values for the appropriate constraint violation. Take the max-width and max-height as max(min, max) so that min ≤ max holds true. In this table w and h stand for the results of the width and height computations [...]</q>
204+
<li>All instances of these words in the table
205+
<li><q>Then apply the rules under "Calculating widths and margins" above, as if 'width' were computed as this value.</q>
206+
</ol>
207+
208+
<li>In <a href="http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-height">10.6.4</a>, <q>height</q> is to be interpreted as <a spec="css21">content height</a> in the following equation: <q>'top' + 'margin-top' + 'border-top-width' + 'padding-top' + 'height' + [...]</q>
209+
210+
<li>In <a href="http://www.w3.org/TR/CSS21/visudet.html#min-max-heights">10.7</a>, <q>width</q>, <q>height</q>, <q>min-height</q> and <q>max-height</q> are respectively to be interpreted as <a spec="css21">content width</a>, <a spec="css21">content height</a>, <a>min inner height</a> and <a>max inner height</a> in the following phrases:
211+
<ol>
212+
<li><q>The tentative used height is calculated [...]</q>
213+
<li><q>If this tentative height is greater than 'max-height', the rules above are applied again, but this time using the value of 'max-height' as the computed value for 'height'.</q>
214+
<li><q>If the resulting height is smaller than 'min-height', the rules above are applied again, but this time using the value of 'min-height' as the computed value for 'height'.</q>
215+
<li><q>[...] use the algorithm under Minimum and maximum widths above to find the used width and height. Then apply the rules under "Computing heights and margins" above, using the resulting width and height as if they were the computed values.</q>
216+
</ol>
217+
</ol>
168218

169219
<div class="example"><p style="display:none">Example(s):
170220
<h4 id="box-sizing-example" class="no-num no-toc">Using box-sizing to evenly share space</h4>
@@ -201,7 +251,7 @@ demonstration of sample CSS and HTML:
201251
</div>
202252
</div>
203253

204-
Note: The ''padding-box'' value is at risk.
254+
Note: The ''box-sizing/padding-box'' value is at risk.
205255

206256
Issue: <a href="https://wiki.csswg.org/spec/css3-ui#issue-69">69</a> box-sizing insufficiently specified for replaced elements.
207257

0 commit comments

Comments
 (0)