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