| <!DOCTYPE html> |
| <meta charset="utf-8"> |
| <title>CSS Grid Layout Test: Intrinsic contribution of a small item to intrinsic tracks</title> |
| <link rel="author" title="Elika J. Etemad" href="http://fantasai.inkedblade.net/contact"> |
| <link rel="help" href="https://www.w3.org/TR/css-grid-1/#algo-content"> |
| <meta name="assert" content="This test checks that the intrinsic contribution of a single grid item smaller than its container is distributed correctly among the tracks it spans when intrinsic tracks are involved."> |
| <link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> |
| <style> |
| #grid { |
| display: grid; |
| width: 120px; |
| height: 120px; |
| border: solid; |
| font: 10px/1 Ahem; |
| } |
| #item { |
| background: blue; |
| /* make min-content contribution differ from minimum contribution */ |
| min-width: 12px; |
| min-height: 12px; |
| } |
| </style> |
| |
| <div id="grid"> |
| <div id="item">XXX XX<br>XX<br>XX</div> |
| </div> |
| |
| <div id="log"></div> |
| |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script src="../grid-definition/support/testing-utils.js"></script> |
| <script> |
| const item = document.getElementById("item"); |
| function checkTrackSizes(span, trackList, expectedCols, expectedRows) { |
| item.style.gridColumn = item.style.gridRow = `span ${span}`; |
| if (!expectedRows) { |
| expectedRows = expectedCols; |
| } |
| TestingUtils.testGridTemplateColumnsRows("grid", trackList, trackList, expectedCols, expectedRows); |
| } |
| |
| setup({ explicit_done: true }); |
| document.fonts.ready.then(() => { |
| // Item spanning a single track |
| checkTrackSizes(1, "auto", "120px"); |
| checkTrackSizes(1, "min-content", "30px", "40px"); |
| checkTrackSizes(1, "max-content", "60px", "30px"); |
| |
| checkTrackSizes(1, "minmax(0, auto)", "120px"); |
| checkTrackSizes(1, "minmax(0, min-content)", "30px", "40px"); |
| checkTrackSizes(1, "minmax(0, max-content)", "60px", "30px"); |
| |
| checkTrackSizes(1, "minmax(auto, 10px)", "12px"); |
| checkTrackSizes(1, "minmax(min-content, 10px)", "30px", "40px"); |
| checkTrackSizes(1, "minmax(max-content, 10px)", "60px", "30px"); |
| |
| // Item spanning two identical tracks |
| |
| checkTrackSizes(2, "auto auto", "60px 60px"); |
| checkTrackSizes(2, "min-content min-content", "15px 15px", "20px 20px"); |
| checkTrackSizes(2, "max-content max-content", "30px 30px", "15px 15px"); |
| |
| checkTrackSizes(2, "minmax(0, auto) minmax(0, auto)", "60px 60px"); |
| checkTrackSizes(2, "minmax(0, min-content) minmax(0, min-content)", "15px 15px", "20px 20px"); |
| checkTrackSizes(2, "minmax(0, max-content) minmax(0, max-content)", "30px 30px", "15px 15px"); |
| |
| checkTrackSizes(2, "minmax(auto, 4px) minmax(auto, 4px)", "6px 6px"); |
| checkTrackSizes(2, "minmax(auto, 10px) minmax(auto, 10px)", "10px 10px"); |
| checkTrackSizes(2, "minmax(min-content, 10px) minmax(min-content, 10px)", "15px 15px", "20px 20px"); |
| checkTrackSizes(2, "minmax(max-content, 10px) minmax(max-content, 10px)", "30px 30px", "15px 15px"); |
| |
| // Item spanning a fixed track also |
| checkTrackSizes(2, "20px auto", "20px 100px"); |
| checkTrackSizes(2, "20px min-content", "20px 10px", "20px 20px"); |
| checkTrackSizes(2, "20px max-content", "20px 40px", "20px 10px"); |
| |
| checkTrackSizes(2, "20px minmax(0, auto)", "20px 100px"); |
| checkTrackSizes(2, "20px minmax(0, min-content)", "20px 10px", "20px 20px"); |
| checkTrackSizes(2, "20px minmax(0, max-content)", "20px 40px", "20px 10px"); |
| |
| checkTrackSizes(2, "20px minmax(auto, 30px)", "20px 30px"); |
| checkTrackSizes(2, "20px minmax(min-content, 6px)", "20px 10px", "20px 20px"); |
| checkTrackSizes(2, "20px minmax(min-content, 40px)", "20px 40px", "20px 40px"); |
| checkTrackSizes(2, "20px minmax(max-content, 6px)", "20px 40px", "20px 10px"); |
| checkTrackSizes(2, "20px minmax(max-content, 30px)", "20px 40px", "20px 30px"); |
| |
| // Item spanning two mismatched intrinsic tracks |
| checkTrackSizes(2, "max-content min-content", "45px 15px", "15px 15px"); |
| |
| done(); |
| }); |
| </script> |