Search code examples
htmlcssoverlaycss-grid

CSS getting block-level transparency


I am working with grid-algorithms and found an image to produce. For some reason the overlay properties are giving my different overlay views than the grid I want.

enter image description here

.grid {
  display: grid;
  grid-template-columns: 40fr 40fr 40fr 40fr;
  grid-template-rows: 100px 100px 100px;
  grid-template-areas: " item1 item1 item1 item1", "item2 item2 item2 item2";
}

.item1 {
   grid-row: span 3;
   grid-column: span 3;
   grid-row-end: span;
   grid-column-end: span; 
   border: .1em solid #c09dac;
   background-color: lightgrey;
   border-color: #80949b;
   border-radius: 25px;
   text-align: center;
}

.item2 {
   grid-row: 2/4;
   grid-column: 2/4;
   grid-column-end: span 1;
   z-index:1; 
   grid-row-end: span;
   border: .1em solid #e2bec5;
   background-color:  #e4bcc4;
   border-color: #e2bec5;
   border-radius: 25px;
   text-align: center;
}
<div class="grid">
  <div class="item1">One</div>
  <div class="item2">Two</div>
</div>


Solution

  • I answered my own question.

    .grid {
      display: grid;
      grid-template-columns: 40fr 40fr 40fr 40fr;
      grid-template-rows: 100px 100px 100px;
      grid-template-areas: " item1 item1 item1 item1", "item2 item2 item2 item2";
    }
    
    .item1 {
       grid-row: 1 / 3;
       grid-column: 1 / 4;
       grid-row-end: span;
       grid-column-end: span;
       border: .1em solid #c09dac;
       background-color: lightgrey;
       border-color: #80949b;
       border-radius: 25px;
       text-align: center;
    }
    
    .item2 {
       grid-row: 2/4;
       grid-column: 2/5;
       grid-column-end: span ;
       z-index:1; 
       grid-row-end: span;
       border: .1em solid #e2bec5;
       background-color:  #e4bcc4;
       border-color: #e2bec5;
       border-radius: 25px;
       text-align: center;
    }
    <div class="grid">
      <div class="item1">One</div>
      <div class="item2">Two</div>
    </div>