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