blob: 313d6136c02f67473d0bdc32973b541c502518e2 [file] [log] [blame]
<!DOCTYPE html>
<link href="../css-intrinsic-dimensions/resources/width-keyword-classes.css" rel="stylesheet">
<link href="resources/grid.css" rel="stylesheet">
<link href="resources/grid-alignment.css" rel="stylesheet">
<script src="../../resources/check-layout.js"></script>
<script src="../../resources/js-test.js"></script>
<style>
body { margin: 0px; }
.grid100And200 {
grid-template-columns: 100px 100px;
grid-template-rows: 200px 200px;
position: relative; /* For the <p> comments */
}
.grid50And100 {
grid: 100px 100px / 50px 50px;
width: 200px;
height: 300px;
position: relative; /* For the <p> comments */
}
.gridAuto20And40 {
grid-auto-columns: 20px;
grid-auto-rows: 40px;
width: 400px;
height: 300px;
position: relative; /* For the <p> comments */
}
.gridWithPaddingBorder {
grid-template-columns: 100px 200px;
grid-template-rows: 200px 200px;
padding: 10px 15px 20px 30px;
border-width: 5px 10px 15px 20px;
border-style: dotted;
border-color: blue;
position: relative; /* For the <p> comments */
}
.gridWithAutoColumns {
grid-auto-columns: 20px;
border: 2px solid black;
width: 10px;
margin-left: 200px;
position: relative;
}
.gridWithAutoRows {
grid-auto-rows: 40px;
border: 2px solid black;
height: 50px;
width: 20px;
position: relative;
}
.stretchedGrid { grid-auto-columns: auto; }
.gridRowColumnGaps {
grid-row-gap: 17px;
grid-column-gap: 21px;
}
div.grid > div { font: 10px/1 Ahem; }
.cell {
width: 20px;
height: 40px;
}
div.gridWithPaddingBorder > div.cell {
margin: 4px 8px 12px 16px;
}
.thirdRowFirstColumn {
background-color: lime;
grid-row: 3;
grid-column: 1;
}
.container {
position: relative;
}
</style>
<body onload="checkLayout('.grid')">
<!-- Check that gutters do not interfere with self alignment computation. -->
<div class="container">
<div class="grid grid100And200 fit-content alignItemsCenter gridRowColumnGaps" data-expected-width="221" data-expected-height="417">
<div class="cell alignSelfAuto firstRowFirstColumn" data-offset-x="0" data-offset-y="80" data-expected-width="20" data-expected-height="40"></div>
<div class="cell firstRowSecondColumn" data-offset-x="121" data-offset-y="80" data-expected-width="20" data-expected-height="40"></div>
<div class="cell alignSelfSelfStart secondRowFirstColumn" data-offset-x="0" data-offset-y="217" data-expected-width="20" data-expected-height="40"></div>
<div class="cell alignSelfSelfEnd secondRowSecondColumn" data-offset-x="121" data-offset-y="377" data-expected-width="20" data-expected-height="40"></div>
</div>
</div>
<div class="container">
<div class="grid grid100And200 fit-content verticalLR gridRowColumnGaps" data-expected-width="417" data-expected-height="221">
<div class="alignSelfStretch firstRowFirstColumn verticalRL" data-offset-x="0" data-offset-y="0" data-expected-width="200" data-expected-height="100">
</div>
<div class="cell alignSelfStart firstRowSecondColumn verticalRL" data-offset-x="0" data-offset-y="121" data-expected-width="20" data-expected-height="40">
<div class="item"></div>
</div>
<div class="cell alignSelfEnd firstRowSecondColumn verticalRL" data-offset-x="180" data-offset-y="121" data-expected-width="20" data-expected-height="40">
<div class="item"></div>
</div>
<div class="cell alignSelfCenter secondRowFirstColumn verticalRL" data-offset-x="307" data-offset-y="0" data-expected-width="20" data-expected-height="40">
<div class="item"></div>
</div>
<div class="cell alignSelfRight secondRowSecondColumn verticalRL" data-offset-x="217" data-offset-y="121" data-expected-width="20" data-expected-height="40">
<div class="item"></div>
</div>
<div class="cell alignSelfLeft secondRowSecondColumn verticalRL" data-offset-x="217" data-offset-y="121" data-expected-width="20" data-expected-height="40">
<div class="item"></div>
</div>
</div>
</div>
<div class="container">
<div class="grid grid100And200 fit-content directionRTL gridRowColumnGaps" data-expected-width="221" data-expected-height="417">
<div class="alignSelfStretch firstRowFirstColumn" data-offset-x="121" data-offset-y="0" data-expected-width="100" data-expected-height="200"></div>
<div class="cell alignSelfStart firstRowSecondColumn" data-offset-x="80" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
<div class="cell alignSelfEnd firstRowSecondColumn" data-offset-x="80" data-offset-y="160" data-expected-width="20" data-expected-height="40"></div>
<div class="cell alignSelfCenter secondRowFirstColumn" data-offset-x="201" data-offset-y="297" data-expected-width="20" data-expected-height="40"></div>
<div class="cell alignSelfRight secondRowSecondColumn" data-offset-x="80" data-offset-y="217" data-expected-width="20" data-expected-height="40"></div>
<div class="cell alignSelfLeft secondRowSecondColumn" data-offset-x="80" data-offset-y="217" data-expected-width="20" data-expected-height="40"></div>
</div>
</div>
<!-- Check that gutters do not interfere with align-content computation. -->
<div class="container">
<p>direction: LTR | align-content: 'center'</p>
<div class="grid grid50And100 alignContentCenter gridRowColumnGaps" data-expected-width="200" data-expected-height="300">
<div class="cell firstRowFirstColumn" data-offset-x="0" data-offset-y="42" data-expected-width="20" data-expected-height="40"></div>
<div class="firstRowSecondColumn" data-offset-x="71" data-offset-y="42" data-expected-width="50" data-expected-height="100"></div>
<div class="secondRowFirstColumn" data-offset-x="0" data-offset-y="159" data-expected-width="50" data-expected-height="100"></div>
<div class="cell secondRowSecondColumn" data-offset-x="71" data-offset-y="159" data-expected-width="20" data-expected-height="40"></div>
</div>
</div>
<div class="container">
<p>direction: LTR | align-content: 'right'</p>
<div class="grid grid50And100 alignContentRight gridRowColumnGaps" data-expected-width="200" data-expected-height="300">
<div class="cell firstRowFirstColumn" data-offset-x="0" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
<div class="firstRowSecondColumn" data-offset-x="71" data-offset-y="0" data-expected-width="50" data-expected-height="100"></div>
<div class="secondRowFirstColumn" data-offset-x="0" data-offset-y="117" data-expected-width="50" data-expected-height="100"></div>
<div class="cell secondRowSecondColumn" data-offset-x="71" data-offset-y="117" data-expected-width="20" data-expected-height="40"></div>
</div>
</div>
<div class="container">
<p>direction: RTL | align-content: 'right'</p>
<div class="grid grid50And100 directionRTL alignContentRight gridRowColumnGaps" data-expected-width="200" data-expected-height="300">
<div class="cell firstRowFirstColumn" data-offset-x="180" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
<div class="firstRowSecondColumn" data-offset-x="79" data-offset-y="0" data-expected-width="50" data-expected-height="100"></div>
<div class="secondRowFirstColumn" data-offset-x="150" data-offset-y="117" data-expected-width="50" data-expected-height="100"></div>
<div class="cell secondRowSecondColumn" data-offset-x="109" data-offset-y="117" data-expected-width="20" data-expected-height="40"></div>
</div>
</div>
<div class="container">
<p>direction: RTL | align-content: 'start'</p>
<div class="grid grid50And100 directionRTL alignContentStart gridRowColumnGaps" data-expected-width="200" data-expected-height="300">
<div class="cell firstRowFirstColumn" data-offset-x="180" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
<div class="firstRowSecondColumn" data-offset-x="79" data-offset-y="0" data-expected-width="50" data-expected-height="100"></div>
<div class="secondRowFirstColumn" data-offset-x="150" data-offset-y="117" data-expected-width="50" data-expected-height="100"></div>
<div class="cell secondRowSecondColumn" data-offset-x="109" data-offset-y="117" data-expected-width="20" data-expected-height="40"></div>
</div>
</div>
<!-- Check that gutters do not interfere with justify-content computation. -->
<div class="container">
<p>direction: LTR | justify-content: 'center'</p>
<div class="grid grid50And100 justifyContentCenter gridRowColumnGaps" data-expected-width="200" data-expected-height="300">
<div class="cell firstRowFirstColumn" data-offset-x="40" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
<div class="firstRowSecondColumn" data-offset-x="111" data-offset-y="0" data-expected-width="50" data-expected-height="100"></div>
<div class="secondRowFirstColumn" data-offset-x="40" data-offset-y="117" data-expected-width="50" data-expected-height="100"></div>
<div class="cell secondRowSecondColumn" data-offset-x="111" data-offset-y="117" data-expected-width="20" data-expected-height="40"></div>
</div>
</div>
<div class="container">
<p>direction: LTR | justify-content: 'end'</p>
<div class="grid grid50And100 justifyContentEnd gridRowColumnGaps" data-expected-width="200" data-expected-height="300">
<div class="cell firstRowFirstColumn" data-offset-x="79" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
<div class="firstRowSecondColumn" data-offset-x="150" data-offset-y="0" data-expected-width="50" data-expected-height="100"></div>
<div class="secondRowFirstColumn" data-offset-x="79" data-offset-y="117" data-expected-width="50" data-expected-height="100"></div>
<div class="cell secondRowSecondColumn" data-offset-x="150" data-offset-y="117" data-expected-width="20" data-expected-height="40"></div>
</div>
</div>
<div class="container">
<p>direction: RTL | justify-content: 'end'</p>
<div class="grid grid50And100 directionRTL justifyContentRight gridRowColumnGaps" data-expected-width="200" data-expected-height="300">
<div class="cell firstRowFirstColumn" data-offset-x="180" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
<div class="firstRowSecondColumn" data-offset-x="79" data-offset-y="0" data-expected-width="50" data-expected-height="100"></div>
<div class="secondRowFirstColumn" data-offset-x="150" data-offset-y="117" data-expected-width="50" data-expected-height="100"></div>
<div class="cell secondRowSecondColumn" data-offset-x="109" data-offset-y="117" data-expected-width="20" data-expected-height="40"></div>
</div>
</div>
<div class="container">
<p>direction: RTL | justify-content: 'start'</p>
<div class="grid grid50And100 directionRTL justifyContentStart gridRowColumnGaps" data-expected-width="200" data-expected-height="300">
<div class="cell firstRowFirstColumn" data-offset-x="180" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
<div class="firstRowSecondColumn" data-offset-x="79" data-offset-y="0" data-expected-width="50" data-expected-height="100"></div>
<div class="secondRowFirstColumn" data-offset-x="150" data-offset-y="117" data-expected-width="50" data-expected-height="100"></div>
<div class="cell secondRowSecondColumn" data-offset-x="109" data-offset-y="117" data-expected-width="20" data-expected-height="40"></div>
</div>
</div>
<!-- Check that gutters do not interfere with vertical justify-content computation. -->
<div class="container">
<p>direction: RTL | justify-content: 'stretch'</p>
<div class="grid gridAuto20And40 stretchedGrid justifyContentStretch verticalLR directionRTL gridRowColumnGaps" data-expected-width="400" data-expected-height="300">
<div class="firstRowFirstColumn" data-offset-x="0" data-offset-y="241" data-expected-width="40" data-expected-height="59"></div>
<div class="firstRowSecondColumn" data-offset-x="0" data-offset-y="161" data-expected-width="40" data-expected-height="59"></div>
<div class="firstRowThirdColumn" data-offset-x="0" data-offset-y="80" data-expected-width="40" data-expected-height="59"></div>
<div class="firstRowFourthColumn" data-offset-x="0" data-offset-y="0" data-expected-width="40" data-expected-height="59"></div>
<div class="secondRowFirstColumn" data-offset-x="57" data-offset-y="241" data-expected-width="40" data-expected-height="59"></div>
<div class="secondRowSecondColumn" data-offset-x="57" data-offset-y="161" data-expected-width="40" data-expected-height="59"></div>
<div class="secondRowThirdColumn" data-offset-x="57" data-offset-y="80" data-expected-width="40" data-expected-height="59"></div>
<div class="secondRowFourthColumn" data-offset-x="57" data-offset-y="0" data-expected-width="40" data-expected-height="59"></div>
</div>
</div>
<div class="container">
<p>direction: LTR | justify-content: 'space-evenly'</p>
<div class="grid gridAuto20And40 justifyContentSpaceEvenly verticalLR directionRTL gridRowColumnGaps" data-expected-width="400" data-expected-height="300">
<div class="firstRowFirstColumn" data-offset-x="0" data-offset-y="231" data-expected-width="40" data-expected-height="20"></div>
<div class="firstRowSecondColumn" data-offset-x="0" data-offset-y="140" data-expected-width="40" data-expected-height="20"></div>
<div class="firstRowThirdColumn" data-offset-x="0" data-offset-y="50" data-expected-width="40" data-expected-height="20"></div>
<div class="secondRowFirstColumn" data-offset-x="57" data-offset-y="231" data-expected-width="40" data-expected-height="20"></div>
<div class="secondRowSecondColumn" data-offset-x="57" data-offset-y="140" data-expected-width="40" data-expected-height="20"></div>
<div class="secondRowThirdColumn" data-offset-x="57" data-offset-y="50" data-expected-width="40" data-expected-height="20"></div>
</div>
</div>
<div class="container">
<p>direction: LTR | justify-content: 'space-between'</p>
<div class="grid gridAuto20And40 justifyContentSpaceBetween verticalRL directionRTL gridRowColumnGaps" data-expected-width="400" data-expected-height="300">
<div class="firstRowFirstColumn" data-offset-x="360" data-offset-y="280" data-expected-width="40" data-expected-height="20"></div>
<div class="firstRowSecondColumn" data-offset-x="360" data-offset-y="187" data-expected-width="40" data-expected-height="20"></div>
<div class="firstRowThirdColumn" data-offset-x="360" data-offset-y="93" data-expected-width="40" data-expected-height="20"></div>
<div class="firstRowFourthColumn" data-offset-x="360" data-offset-y="0" data-expected-width="40" data-expected-height="20"></div>
<div class="secondRowFirstColumn" data-offset-x="303" data-offset-y="280" data-expected-width="40" data-expected-height="20"></div>
<div class="secondRowSecondColumn" data-offset-x="303" data-offset-y="187" data-expected-width="40" data-expected-height="20"></div>
<div class="secondRowThirdColumn" data-offset-x="303" data-offset-y="93" data-expected-width="40" data-expected-height="20"></div>
<div class="secondRowFourthColumn" data-offset-x="303" data-offset-y="0" data-expected-width="40" data-expected-height="20"></div>
</div>
</div>
<div class="container">
<p>direction: LTR | justify-content: 'space-around'</p>
<div class="grid gridAuto20And40 justifyContentSpaceAround verticalRL directionRTL gridRowColumnGaps" data-expected-width="400" data-expected-height="300">
<div class="firstRowFirstColumn" data-offset-x="360" data-offset-y="220" data-expected-width="40" data-expected-height="20"></div>
<div class="firstRowSecondColumn" data-offset-x="360" data-offset-y="60" data-expected-width="40" data-expected-height="20"></div>
<div class="secondRowFirstColumn" data-offset-x="303" data-offset-y="220" data-expected-width="40" data-expected-height="20"></div>
<div class="secondRowSecondColumn" data-offset-x="303" data-offset-y="60" data-expected-width="40" data-expected-height="20"></div>
</div>
</div>
<!-- Check that gutters do not interfere with align&justify computation when having border, padding and margins. -->
<div class="container">
<p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br>
direction: LTR (parall) | align-items: 'self-start' | justify-items: 'self-start'</p>
<div class="grid gridWithPaddingBorder fit-content directionLTR itemsSelfStart gridRowColumnGaps" data-expected-width="396" data-expected-height="467">
<div class="directionLTR cell firstRowFirstColumn" data-offset-x="46" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div>
<div class="directionLTR selfStretch firstRowSecondColumn" data-offset-x="151" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div>
<div class="directionLTR selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="227" data-expected-width="100" data-expected-height="200"></div>
<div class="directionLTR cell secondRowSecondColumn" data-offset-x="167" data-offset-y="231" data-expected-width="20" data-expected-height="40"></div>
</div>
</div>
<div class="container">
<p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br>
direction: LTR (ortho) | align-items: 'self-end' | justify-items: 'self-end'</p>
<div class="grid gridWithPaddingBorder fit-content directionLTR itemsSelfEnd gridRowColumnGaps" data-expected-width="396" data-expected-height="467">
<div class="directionRTL cell firstRowFirstColumn" data-offset-x="46" data-offset-y="158" data-expected-width="20" data-expected-height="40"></div>
<div class="directionRTL selfStretch firstRowSecondColumn" data-offset-x="151" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div>
<div class="directionRTL selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="227" data-expected-width="100" data-expected-height="200"></div>
<div class="directionRTL cell secondRowSecondColumn" data-offset-x="167" data-offset-y="375" data-expected-width="20" data-expected-height="40"></div>
</div>
</div>
<div class="container">
<p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br>
direction: RTL | align-items: 'right' | justify-items: 'right'</p>
<div class="grid gridWithPaddingBorder fit-content directionRTL itemsRight gridRowColumnGaps" data-expected-width="396" data-expected-height="467">
<div class="cell firstRowFirstColumn" data-offset-x="323" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div>
<div class="selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div>
<div class="selfStretch secondRowFirstColumn" data-offset-x="251" data-offset-y="227" data-expected-width="100" data-expected-height="200"></div>
<div class="cell secondRowSecondColumn" data-offset-x="202" data-offset-y="231" data-expected-width="20" data-expected-height="40"></div>
</div>
</div>
<div class="container">
<p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br>
direction: RTL (parall) | align-items: 'self-start' | justify-items: 'self-start'</p>
<div class="grid gridWithPaddingBorder fit-content directionRTL itemsSelfStart gridRowColumnGaps" data-expected-width="396" data-expected-height="467">
<div class="directionRTL cell firstRowFirstColumn" data-offset-x="323" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div>
<div class="directionRTL selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div>
<div class="directionRTL selfStretch secondRowFirstColumn" data-offset-x="251" data-offset-y="227" data-expected-width="100" data-expected-height="200"></div>
<div class="directionRTL cell secondRowSecondColumn" data-offset-x="202" data-offset-y="231" data-expected-width="20" data-expected-height="40"></div>
</div>
</div>
<!-- Check behavior with negative free space -->
<div class="container">
<p>Negative free space. justify-content: start</p>
<div class="grid gridWithAutoColumns justifyContentStart gridRowColumnGaps" data-expected-width="14" data-expected-height="44">
<div class="cell firstRowFirstColumn" data-offset-x="0" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
<div class="cell firstRowSecondColumn" data-offset-x="41" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
<div class="cell firstRowThirdColumn" data-offset-x="82" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
</div>
</div>
<div class="container">
<p>Negative free space. justify-content: center</p>
<div class="grid gridWithAutoColumns justifyContentCenter gridRowColumnGaps" data-expected-width="14" data-expected-height="44">
<div class="cell firstRowFirstColumn" data-offset-x="-46" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
<div class="cell firstRowSecondColumn" data-offset-x="-5" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
<div class="cell firstRowThirdColumn" data-offset-x="36" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
</div>
</div>
<div class="container">
<p>Negative free space. justify-content: end</p>
<div class="grid gridWithAutoColumns justifyContentEnd gridRowColumnGaps" data-expected-width="14" data-expected-height="44">
<div class="cell firstRowFirstColumn" data-offset-x="-92" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
<div class="cell firstRowSecondColumn" data-offset-x="-51" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
<div class="cell firstRowThirdColumn" data-offset-x="-10" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
</div>
</div>
<!-- NOTE: for the following 3 test cases we use margins just for enhancing the visual output (otherwise grids would overlap) -->
<div class="container" style="margin-bottom: 125px;">
<p>Negative free space. align-content: start</p>
<div class="grid gridWithAutoRows alignContentStart gridRowColumnGaps" data-expected-width="24" data-expected-height="54">
<div class="cell firstRowFirstColumn" data-offset-x="0" data-offset-y="0" data-expected-width="20" data-expected-height="40"></div>
<div class="cell secondRowFirstColumn" data-offset-x="0" data-offset-y="57" data-expected-width="20" data-expected-height="40"></div>
<div class="cell thirdRowFirstColumn" data-offset-x="0" data-offset-y="114" data-expected-width="20" data-expected-height="40"></div>
</div>
</div>
<div class="container" style="margin-bottom: 75px;">
<p>Negative free space. align-content: center</p>
<div class="grid gridWithAutoRows alignContentCenter gridRowColumnGaps" style="margin-top: 75px" data-expected-width="24" data-expected-height="54">
<div class="cell firstRowFirstColumn" data-offset-x="0" data-offset-y="-52" data-expected-width="20" data-expected-height="40"></div>
<div class="cell secondRowFirstColumn" data-offset-x="0" data-offset-y="5" data-expected-width="20" data-expected-height="40"></div>
<div class="cell thirdRowFirstColumn" data-offset-x="0" data-offset-y="62" data-expected-width="20" data-expected-height="40"></div>
</div>
</div>
<div class="container" style="margin-bottom: 25px;">
<p>Negative free space. align-content: end</p>
<div class="grid gridWithAutoRows alignContentEnd gridRowColumnGaps" style="margin-top: 125px" data-expected-width="24" data-expected-height="54">
<div class="cell firstRowFirstColumn" data-offset-x="0" data-offset-y="-104" data-expected-width="20" data-expected-height="40"></div>
<div class="cell secondRowFirstColumn" data-offset-x="0" data-offset-y="-47" data-expected-width="20" data-expected-height="40"></div>
<div class="cell thirdRowFirstColumn" data-offset-x="0" data-offset-y="10" data-expected-width="20" data-expected-height="40"></div>
</div>
</div>
</body>