You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and acts as spacing above the margin-top of an element. It is used to
1375
1379
push the element vertically past the float.
1376
1380
1377
-
<p>
1378
-
Computing the clearance of an element on which 'clear' is set is done by first determining the hypothetical position of the element's top border edge within its parent block. This position is determined after the top margin of the element has been collapsed with previous adjacent margins (including the top margin of the parent block).
1379
-
</p>
1380
-
<p>
1381
-
If this hypothetical position of the element's top border edge is not
1382
-
past the relevant floats, then clearance is introduced and must be set
1383
-
to the greater of:
1384
-
</p>
1381
+
<p>Computing the clearance of an element on which 'clear' is set is
1382
+
done by first determining the hypothetical position of the element's
1383
+
top border edge within its parent block. This position is the same as
1384
+
the where the actual top border edge would have been if the element
1385
+
had a non-zero top border and its 'clear' property had been 'none'.
1386
+
1387
+
<p>If this hypothetical position of the element's top border edge is
1388
+
not past the relevant floats, then clearance is introduced, and
1389
+
margins collapse according to the rules in 8.3.1.
1390
+
1391
+
<p>Then the amount of clearance is set to the greater of:
1392
+
1385
1393
<ol>
1386
1394
<li>The amount necessary to place the border edge of the block even
1387
1395
with the bottom outer edge of the lowest float that is to be
1388
1396
cleared.
1389
1397
1390
-
<li>The amount necessary to make the sum of the following equal to
1391
-
the distance to which these margins collapsed when the hypothetical
1392
-
position was calculated:
1393
-
<ul>
1394
-
<li>the margins collapsing above the clearance
1395
-
1396
-
<li>the clearance itself
1397
-
1398
-
<li>if the block's own margins collapse together: the block's top
1399
-
margin
1400
-
1401
-
<li>if the block's own margins do not collapse together: the
1402
-
margins collapsing below the clearance
1403
-
</ul>
1398
+
<li>The amount necessary to place the top border edge of the block
1399
+
at its hypothetical position.
1404
1400
</ol>
1405
1401
<p class=note>
1406
1402
Note: The clearance can be negative or zero.
1407
1403
1408
1404
<div class=example>
1409
-
<p>An example of negative clearance is this situation, in which the
1405
+
<p>Example 1. Assume (for the sake of simplicity), that we have just
1406
+
three boxes, in this order: block B1 with a bottom margin of M1 (B1
1407
+
has no children and no padding or border), floating block F with a
1408
+
height H, and block B2 with a top margin of M2 (no padding or border,
1409
+
no children). B2 has 'clear' set to 'both'. We also assume B2 is not
1410
+
empty.
1411
+
1412
+
<p>Without considering the 'clear' property on B2, we have the situation in
1413
+
the diagram below. The margins of B1 and B2 collapse. Let's say the
1414
+
bottom border edge of B1 is at y = 0, then the top of F is at y = M1,
1415
+
the top border edge of B2 is at y = max(M1,M2), and the bottom of F is
1416
+
at y = M1 + H.
1417
+
1418
+
<div class="figure">
1419
+
<p><img src="./images/clearance.png"
1420
+
alt="Float F extends into the margin above M2."></p>
1421
+
</div>
1422
+
1423
+
<p>We also assume that B2 is not below F, i.e., we are in the
1424
+
situation described in the spec where we need to add clearance. That
1425
+
means:
1426
+
1427
+
<blockquote>
1428
+
<p>max(M1,M2) < M1 + H
1429
+
</blockquote>
1430
+
1431
+
<p>We need to compute clearance C twice, C1 and C2, and
1432
+
keep the greater of the two: C = max(C1,C2). The first way is to put
1433
+
the top of B2 flush with the bottom of F, i.e., at y = M1 + H. That
1434
+
means, because the margins no longer collapse with a clearance between
1435
+
them:
1436
+
1437
+
<blockquote class=math>
1438
+
<p> <span>bottom of F</span> <span>= top border edge of B2</span> <span>⇔</span>
0 commit comments