.grid-container { display: grid; /* Define 3 columns and 2 rows, each 1fr wide/tall */ grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); width: 500px; height: 300px; background-color: #f0f8ff; /* Alice Blue */ border: 2px dashed #a0d9ff; position: relative; /* Essential for z-index to work relative to container */ font-family: sans-serif; font-size: 1.2em; font-weight: bold; color: white; } .grid-item { display: flex; justify-content: center; align-items: center; padding: 10px; border: 1px solid rgba(255,255,255,0.5); border-radius: 5px; } /* Item A: Spans columns 1 to 3 (covers first two columns) and row 1 */ .item-a { grid-column: 1 / 3; grid-row: 1 / 2; background-color: rgba(255, 99, 71, 0.8); /* Tomato */ z-index: 1; /* Bring to front relative to other items in the same grid area */ } /* Item B: Spans columns 2 to 4 (covers last two columns) and rows 1 to 3 (covers both rows) */ .item-b { grid-column: 2 / 4; grid-row: 1 / 3; background-color: rgba(60, 179, 113, 0.8); /* Medium Sea Green */ z-index: 2; /* Bring even further to front */ } /* Item C: Standard placement, but will be partially hidden by Item B due to z-index */ .item-c { grid-column: 1 / 2; grid-row: 2 / 3; background-color: rgba(70, 130, 180, 0.8); /* Steel Blue */ z-index: 0; } /* Example HTML structure:
Layer 1 (Item A)
Layer 2 (Item B)
Layer 3 (Item C)
*/