positioned-grid-items-negative-indices-001.html (1346B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>CSS Grid Layout Test: Absolutely positioned items with negative indices</title> 4 <link rel="help" href="https://drafts.csswg.org/css-grid-2/#abspos"> 5 <link rel="match" href="positioned-grid-items-negative-indices-001-ref.html"> 6 <meta name="assert" content="Checks that absolutely positioned items are properly placed and sized when they have negative indices."> 7 <style> 8 #grid { 9 display: grid; 10 grid: 150px 100px / 200px 300px; 11 margin: 1px 2px 3px 4px; 12 padding: 20px 15px 10px 5px; 13 border-width: 9px 3px 12px 6px; 14 border-style: solid; 15 width: 550px; 16 height: 400px; 17 position: relative; 18 } 19 20 #grid > div { 21 position: absolute; 22 } 23 24 #firstItem { 25 background: magenta; 26 grid-column: -3 / -2; 27 grid-row: -3 / -2; 28 } 29 30 #secondItem { 31 background: cyan; 32 grid-column: -2 / -1; 33 grid-row: -3 / -2; 34 } 35 36 #thirdItem { 37 background: yellow; 38 grid-column: -3 / -2; 39 grid-row: -2 / -1; 40 } 41 42 #fourthItem { 43 background: lime; 44 grid-column: -2 / -1; 45 grid-row: -2 / -1; 46 } 47 </style> 48 49 <p>The test passes if it has the same output than the reference.</p> 50 <div id="grid"> 51 <div id="firstItem">First item</div> 52 <div id="secondItem">Second item</div> 53 <div id="thirdItem">Third item</div> 54 <div id="fourthItem">Fourth item</div> 55 </div>