OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <style> |
| 3 body { |
| 4 font: 10px Ahem; |
| 5 } |
| 6 .containLayout { |
| 7 contain: strict; |
| 8 background-color: green; |
| 9 } |
| 10 .sized { |
| 11 height: 20px; |
| 12 width: 10px; |
| 13 } |
| 14 .overhangingFloat { |
| 15 float: left; |
| 16 width: 10px; |
| 17 height: 50px; |
| 18 background-color: papayawhip; |
| 19 } |
| 20 .inlineBlock { |
| 21 display: inline-block; |
| 22 } |
| 23 .testContainer { |
| 24 line-height: 15px; |
| 25 } |
| 26 .absolute { |
| 27 position: absolute; |
| 28 left: 200px; |
| 29 } |
| 30 </style> |
| 31 |
| 32 Test an unsized contained block collapses. |
| 33 <div class="containLayout" data-expected-height=0><div class="sized"></div></div
> |
| 34 |
| 35 Test a sized contained block respects its size, not its content's size. |
| 36 <div class="containLayout sized" data-expected-height=20><div class="overhanging
Float"></div></div> |
| 37 |
| 38 Test that the contents of an unsized contained block doesn't effect its parent. |
| 39 <div class="testContainer" data-expected-height=0> |
| 40 <div class="containLayout" data-expected-height=0><div class="overhangingFlo
at"></div></div> |
| 41 </div> |
| 42 |
| 43 Test that the contents of an unsized contained inline-block doesn't change the b
aseline |
| 44 of its parent. Having an inline-block (or other replaced content), even if it's
empty, |
| 45 creates a line, hence we get a line-height worth of height. |
| 46 <div class="testContainer" data-expected-height=15> |
| 47 <div class="containLayout inlineBlock" data-expected-height=0><div class="ov
erhangingFloat"></div></div> |
| 48 </div> |
| 49 |
| 50 Test a sized inline-block uses the proper baseline. Result is 25 instead of 20 d
ue to |
| 51 normal inline layout shenanigans. |
| 52 <div class="testContainer" data-expected-height=25> |
| 53 <div class="containLayout inlineBlock sized" data-expected-height=20><div cl
ass="overhangingFloat"></div></div> |
| 54 </div> |
| 55 |
| 56 Test that a contained block avoids floats. |
| 57 <div class="absolute" style="top: 100px; width: 10px;"> |
| 58 <div class="overhangingFloat"></div> |
| 59 <div class="containLayout sized" data-offset-y=50></div> |
| 60 </div> |
| 61 |
| 62 Test that a contained inline-block avoids floats. |
| 63 <div class="absolute" style="top: 200px width: 100px;"> |
| 64 <div class="overhangingFloat"></div> |
| 65 <div class="containLayout sized inlineBlock" data-offset-x=10></div> |
| 66 </div> |
| 67 |
| 68 <script src="../../../resources/check-layout.js"></script> |
| 69 <script> |
| 70 checkLayout('.testContainer'); |
| 71 checkLayout('.containLayout'); |
| 72 </script> |
OLD | NEW |