Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-grid/grid-items/grid-items-minimum-width-orthogonal-001.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Grid Layout Test: Mininum width of grid items orthogonal</title>
<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com">
<meta name="assert" content="Checks that orthogonal grid items minimum width takes into account borders, padding and margins for grid containers with definite width.">
<link rel="stylesheet" href="/css/support/grid.css">
<style>
.grid {
width: 100px;
border: solid thick;
grid: 10px 10px / minmax(auto, 0px);
}
.grid > div:nth-child(1) { background: cyan; writing-mode: vertical-lr; }
.grid > div:nth-child(2) { background: magenta; }
.width60 { width: 60px; }
.minWidth60 { min-width: 60px; }
.marginLeft5 { margin-left: 5px; }
.marginRight10 { margin-right: 10px; }
.marginTopAuto { margin-top: auto }
.paddingLeft6 { padding-left: 6px; }
.paddingRight3 { padding-right: 3px; }
.borderLeft2, .borderRight4 { border: solid yellow 0px; }
.borderLeft2 { border-left-width: 2px; }
.borderRight4 { border-right-width: 4px; }
</style>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<body onload="checkLayout('.grid')">
<div id="log"></div>
<h3>Direction LTR</h3>
<pre>Item width: 60px;</pre>
<div class="grid">
<div class="width60" data-expected-width="60"></div>
<div data-expected-width="60"></div>
</div>
<pre>Item min-width: 60px;</pre>
<div class="grid">
<div class="minWidth60" data-expected-width="60"></div>
<div data-expected-width="60"></div>
</div>
<pre>Item width: 60px; & margin-left: 5px;</pre>
<div class="grid">
<div class="width60 marginLeft5" data-expected-width="60"></div>
<div data-expected-width="65"></div>
</div>
<pre>Item min-width: 60px; & margin-left: 5px;</pre>
<div class="grid">
<div class="minWidth60 marginLeft5" data-expected-width="60"></div>
<div data-expected-width="65"></div>
</div>
<pre>Item min-width: 60px; & margin-left: 5px; & margin-top: auto</pre>
<div class="grid">
<div class="minWidth60 marginLeft5 marginTopAuto" data-expected-width="60"></div>
<div data-expected-width="65"></div>
</div>
<pre>Item width: 60px; & margin-right: 10px;</pre>
<div class="grid">
<div class="width60 marginRight10" data-expected-width="60"></div>
<div data-expected-width="70"></div>
</div>
<pre>Item min-width: 60px; & margin-right: 10px;</pre>
<div class="grid">
<div class="minWidth60 marginRight10" data-expected-width="60"></div>
<div data-expected-width="70"></div>
</div>
<pre>Item width: 60px; & margin-left: 5px; & margin-right: 10px;</pre>
<div class="grid">
<div class="width60 marginLeft5 marginRight10" data-expected-width="60"></div>
<div data-expected-width="75"></div>
</div>
<pre>Item min-width: 60px; & margin-left: 5px; & margin-right: 10px;</pre>
<div class="grid">
<div class="minWidth60 marginLeft5 marginRight10" data-expected-width="60"></div>
<div data-expected-width="75"></div>
</div>
<pre>Item width: 60px; & padding-left: 6px;</pre>
<div class="grid">
<div class="width60 paddingLeft6" data-expected-width="66"></div>
<div data-expected-width="66"></div>
</div>
<pre>Item min-width: 60px; & padding-left: 6px;</pre>
<div class="grid">
<div class="minWidth60 paddingLeft6" data-expected-width="66"></div>
<div data-expected-width="66"></div>
</div>
<pre>Item width: 60px; & padding-right: 3px;</pre>
<div class="grid">
<div class="width60 paddingRight3" data-expected-width="63"></div>
<div data-expected-width="63"></div>
</div>
<pre>Item min-width: 60px; & padding-right: 3px;</pre>
<div class="grid">
<div class="minWidth60 paddingRight3" data-expected-width="63"></div>
<div data-expected-width="63"></div>
</div>
<pre>Item width: 60px; & padding-left: 6px; & padding-right: 3px;</pre>
<div class="grid">
<div class="width60 paddingLeft6 paddingRight3" data-expected-width="69"></div>
<div data-expected-width="69"></div>
</div>
<pre>Item min-width: 60px; & padding-left: 6px; & padding-right: 3px;</pre>
<div class="grid">
<div class="minWidth60 paddingLeft6 paddingRight3" data-expected-width="69"></div>
<div data-expected-width="69"></div>
</div>
<pre>Item width: 60px; & border-left-width: 2px;</pre>
<div class="grid">
<div class="width60 borderLeft2" data-expected-width="62"></div>
<div data-expected-width="62"></div>
</div>
<pre>Item min-width: 60px; & border-left-width: 2px;</pre>
<div class="grid">
<div class="minWidth60 borderLeft2" data-expected-width="62"></div>
<div data-expected-width="62"></div>
</div>
<pre>Item width: 60px; & border-right-width: 4px;</pre>
<div class="grid">
<div class="width60 borderRight4" data-expected-width="64"></div>
<div data-expected-width="64"></div>
</div>
<pre>Item min-width: 60px; & border-right-width: 4px;</pre>
<div class="grid">
<div class="minWidth60 borderRight4" data-expected-width="64"></div>
<div data-expected-width="64"></div>
</div>
<pre>Item width: 60px; & border-left-width: 2px; & border-right-width: 4px;</pre>
<div class="grid">
<div class="width60 borderLeft2 borderRight4" data-expected-width="66"></div>
<div data-expected-width="66"></div>
</div>
<pre>Item min-width: 60px; & border-left-width: 2px; & border-right-width: 4px;</pre>
<div class="grid">
<div class="minWidth60 borderLeft2 borderRight4" data-expected-width="66"></div>
<div data-expected-width="66"></div>
</div>
<pre>Item width: 60px; & margin-left: 5px; & margin-right: 10px; & padding-left: 6px; & padding-right: 3px; & border-left-width: 2px; & border-right-width: 4px;</pre>
<div class="grid">
<div class="width60 marginLeft5 marginRight10 paddingLeft6 paddingRight3 borderLeft2 borderRight4" data-expected-width="75"></div>
<div data-expected-width="90"></div>
</div>
<pre>Item min-width: 60px; & margin-left: 5px; & margin-right: 10px; & padding-left: 6px; & padding-right: 3px; & border-left-width: 2px; & border-right-width: 4px;</pre>
<div class="grid">
<div class="minWidth60 marginLeft5 marginRight10 paddingLeft6 paddingRight3 borderLeft2 borderRight4" data-expected-width="75"></div>
<div data-expected-width="90"></div>
</div>
<h3>Direction RTL</h3>
<pre>Item width: 60px;</pre>
<div class="grid directionRTL">
<div class="width60" data-expected-width="60"></div>
<div data-expected-width="60"></div>
</div>
<pre>Item min-width: 60px;</pre>
<div class="grid directionRTL">
<div class="minWidth60" data-expected-width="60"></div>
<div data-expected-width="60"></div>
</div>
<pre>Item width: 60px; & margin-left: 5px;</pre>
<div class="grid directionRTL">
<div class="width60 marginLeft5" data-expected-width="60"></div>
<div data-expected-width="65"></div>
</div>
<pre>Item min-width: 60px; & margin-left: 5px;</pre>
<div class="grid directionRTL">
<div class="minWidth60 marginLeft5" data-expected-width="60"></div>
<div data-expected-width="65"></div>
</div>
<pre>Item min-width: 60px; & margin-left: 5px; & margin-top: auto</pre>
<div class="grid directionRTL">
<div class="minWidth60 marginLeft5 marginTopAuto" data-expected-width="60"></div>
<div data-expected-width="65"></div>
</div>
<pre>Item width: 60px; & margin-right: 10px;</pre>
<div class="grid directionRTL">
<div class="width60 marginRight10" data-expected-width="60"></div>
<div data-expected-width="70"></div>
</div>
<pre>Item min-width: 60px; & margin-right: 10px;</pre>
<div class="grid directionRTL">
<div class="minWidth60 marginRight10" data-expected-width="60"></div>
<div data-expected-width="70"></div>
</div>
<pre>Item width: 60px; & margin-left: 5px; & margin-right: 10px;</pre>
<div class="grid directionRTL">
<div class="width60 marginLeft5 marginRight10" data-expected-width="60"></div>
<div data-expected-width="75"></div>
</div>
<pre>Item min-width: 60px; & margin-left: 5px; & margin-right: 10px;</pre>
<div class="grid directionRTL">
<div class="minWidth60 marginLeft5 marginRight10" data-expected-width="60"></div>
<div data-expected-width="75"></div>
</div>
<pre>Item width: 60px; & padding-left: 6px;</pre>
<div class="grid directionRTL">
<div class="width60 paddingLeft6" data-expected-width="66"></div>
<div data-expected-width="66"></div>
</div>
<pre>Item min-width: 60px; & padding-left: 6px;</pre>
<div class="grid directionRTL">
<div class="minWidth60 paddingLeft6" data-expected-width="66"></div>
<div data-expected-width="66"></div>
</div>
<pre>Item width: 60px; & padding-right: 3px;</pre>
<div class="grid directionRTL">
<div class="width60 paddingRight3" data-expected-width="63"></div>
<div data-expected-width="63"></div>
</div>
<pre>Item min-width: 60px; & padding-right: 3px;</pre>
<div class="grid directionRTL">
<div class="minWidth60 paddingRight3" data-expected-width="63"></div>
<div data-expected-width="63"></div>
</div>
<pre>Item width: 60px; & padding-left: 6px; & padding-right: 3px;</pre>
<div class="grid directionRTL">
<div class="width60 paddingLeft6 paddingRight3" data-expected-width="69"></div>
<div data-expected-width="69"></div>
</div>
<pre>Item min-width: 60px; & padding-left: 6px; & padding-right: 3px;</pre>
<div class="grid directionRTL">
<div class="minWidth60 paddingLeft6 paddingRight3" data-expected-width="69"></div>
<div data-expected-width="69"></div>
</div>
<pre>Item width: 60px; & border-left-width: 2px;</pre>
<div class="grid directionRTL">
<div class="width60 borderLeft2" data-expected-width="62"></div>
<div data-expected-width="62"></div>
</div>
<pre>Item min-width: 60px; & border-left-width: 2px;</pre>
<div class="grid directionRTL">
<div class="minWidth60 borderLeft2" data-expected-width="62"></div>
<div data-expected-width="62"></div>
</div>
<pre>Item width: 60px; & border-right-width: 4px;</pre>
<div class="grid directionRTL">
<div class="width60 borderRight4" data-expected-width="64"></div>
<div data-expected-width="64"></div>
</div>
<pre>Item min-width: 60px; & border-right-width: 4px;</pre>
<div class="grid directionRTL">
<div class="minWidth60 borderRight4" data-expected-width="64"></div>
<div data-expected-width="64"></div>
</div>
<pre>Item width: 60px; & border-left-width: 2px; & border-right-width: 4px;</pre>
<div class="grid directionRTL">
<div class="width60 borderLeft2 borderRight4" data-expected-width="66"></div>
<div data-expected-width="66"></div>
</div>
<pre>Item min-width: 60px; & border-left-width: 2px; & border-right-width: 4px;</pre>
<div class="grid directionRTL">
<div class="minWidth60 borderLeft2 borderRight4" data-expected-width="66"></div>
<div data-expected-width="66"></div>
</div>
<pre>Item width: 60px; & margin-left: 5px; & margin-right: 10px; & padding-left: 6px; & padding-right: 3px; & border-left-width: 2px; & border-right-width: 4px;</pre>
<div class="grid directionRTL">
<div class="width60 marginLeft5 marginRight10 paddingLeft6 paddingRight3 borderLeft2 borderRight4" data-expected-width="75"></div>
<div data-expected-width="90"></div>
</div>
<pre>Item min-width: 60px; & margin-left: 5px; & margin-right: 10px; & padding-left: 6px; & padding-right: 3px; & border-left-width: 2px; & border-right-width: 4px;</pre>
<div class="grid directionRTL">
<div class="minWidth60 marginLeft5 marginRight10 paddingLeft6 paddingRight3 borderLeft2 borderRight4" data-expected-width="75"></div>
<div data-expected-width="90"></div>
</div>