html - Flex grid not aligning -


i have grid have built out of flex boxes. of grid made of squares, 2 rectangles. can't seem boxes align correctly, using flexbox flex-grow, or manually setting box heights. goal have them line equal margins between entire grid. here grid code:

.project-grid { height: 1400px; padding: 80px 20px;  }  .project-grid .column  { width:33.33%; margin-left:10px; flex-direction:column; margin-top:-10px; }  .project-grid .column:first-child { margin-left:0; }  .project-grid .column .box  {  margin-top:10px;  background-color:blue;  height: 400px;  background-size:cover;  background-repeat: no-repeat;}  .project-grid .column .box.tall  { height:800px; }    .project-grid .column .box > p {  font-family: $lato;  color: $white;  font-size: 24px;}  .flex  { display:flex;}
<div class="project-grid flex">                  <div class="flex column">                      <a href="/hospitality">                          <div class="box" style="background-image: url('');" <a href="/projects">                              <p>hospitality</p>                          </div>                      </a>                      <a href="/rennovation-repurpose">                          <div class="box tall" style="background-image: url('');">                              <p>rennovation/ repurpose</p>                          </div>                      </a>                  </div>                  <div class="flex column">                      <a href="/automotive">                          <div class="box" style="background-image: url('');">                              <p>automotive</p>                          </div>                      </a>                      <a href="/serenbe">                          <div class="box" style="background-image: url('');">                              <p>serenbe</p>                          </div>                      </a>                      <a href="/retail-office">                          <div class="box" style="background-image: url('')    ;">                              <p>retail/ office</p>                          </div>                      </a>                  </div>                  <div class="flex column">                      <a href="/multi-family-mixed-use">                          <div class="box tall" style="background-image: url('');">                              <p>multi-family/ mixed use</p>                          </div>                      </a>                      <a href="/education-places-of-worship">                          <div class="box" style="background-image: url('');">                              <p>education/ places of worship</p>                          </div>                      </a>                  </div>              </div>  css

for easy viewing, here codepen i've made: https://codepen.io/bsquared/pen/zdpqpj

as commented, if involved <a> in flex layout , draw background, can achieve visual for.

a {    /*with no fix height can spread evenly if needed*/    background: blue;    /* draw bg here include children area , further if needed visual */    margin: 10px;    /* set margins here */    color: white;  }      /* flex layout , sizing */    .flex,  {    display: flex;  }    .column,  {    flex-direction: column;    flex: 1;/* make fill entire space left if */  }    .box {    height: 400px;  }    .tall {    height: 800px;  }
<div class="project-grid flex">    <div class="flex column">      <a href="/hospitality">        <div class="box" style="background-image: url('');"><!-- background-image send & set parent -->          <p>hospitality</p>        </div>      </a>      <a href="/rennovation-repurpose">        <div class="box tall" style="background-image: url('');">          <p>rennovation/ repurpose</p>        </div>      </a>    </div>    <div class="flex column">      <a href="/automotive">        <div class="box" style="background-image: url('');">          <p>automotive</p>        </div>      </a>      <a href="/serenbe">        <div class="box" style="background-image: url('');">          <p>serenbe</p>        </div>      </a>      <a href="/retail-office">        <div class="box" style="background-image: url('')    ;">          <p>retail/ office</p>        </div>      </a>    </div>    <div class="flex column">      <a href="/multi-family-mixed-use">        <div class="box tall" style="background-image: url('');">          <p>multi-family/ mixed use</p>        </div>      </a>      <a href="/education-places-of-worship">        <div class="box" style="background-image: url('');">          <p>education/ places of worship</p>        </div>      </a>    </div>  </div>


if want keep heights, need mind amounts of margins eights of elements in each column :

example

.project-grid { height: 1400px; padding: 80px 20px;  }  .project-grid .column  { width:33.33%; margin-left:10px; flex-direction:column; margin-top:-10px; }  .project-grid .column:first-child { margin-left:0; }  .project-grid .column .box  {  margin-top:10px;  background-color:blue;  height: 400px;  background-size:cover;  background-repeat: no-repeat;}  .project-grid .column .box.tall  { height:824px; }    .project-grid .column .box > p {  font-family: $lato;  color: $white;  font-size: 24px;}  .flex  { display:flex;}
<div class="project-grid flex">                  <div class="flex column">                      <a href="/hospitality">                          <div class="box" style="background-image: url('');" >                              <p>hospitality</p>                          </div>                      </a>                      <a href="/rennovation-repurpose">                          <div class="box tall" style="background-image: url('');">                              <p>rennovation/ repurpose</p>                          </div>                      </a>                  </div>                  <div class="flex column">                      <a href="/automotive">                          <div class="box" style="background-image: url('');">                              <p>automotive</p>                          </div>                      </a>                      <a href="/serenbe">                          <div class="box" style="background-image: url('');">                              <p>serenbe</p>                          </div>                      </a>                      <a href="/retail-office">                          <div class="box" style="background-image: url('')    ;">                              <p>retail/ office</p>                          </div>                      </a>                  </div>                  <div class="flex column">                      <a href="/multi-family-mixed-use">                          <div class="box tall" style="background-image: url('');">                              <p>multi-family/ mixed use</p>                          </div>                      </a>                      <a href="/education-places-of-worship">                          <div class="box" style="background-image: url('');">                              <p>education/ places of worship</p>                          </div>                      </a>                  </div>              </div>  css


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -