Hex Honeycomb Pattern

I’m building off of another codepen I found with rows of responsive hexagrams. Each hex has a hover affect where the top and bottom are supposed to come together. However there is a space between the top and bottom overlay section.

Here is my codepen https://codepen.io/aaron4osu/pen/YzYjXKY

here is the css

* {
    margin: 0;
    padding: 0;
}
body {
   
}
#hexGrid {
  display: flex;
  flex-wrap: wrap;
  width: 90%;
  margin: 0 auto;
  overflow: hidden;
  font-size: 15px;
  list-style-type: none;
}

.hex {
  position: relative;
  visibility:hidden;
  outline:1px solid transparent; /* fix for jagged edges in FF on hover transition */
}
.hex::after{
  content:'';
  display:block;
  padding-bottom: 86.602%;  /* =  100 / tan(60) * 1.5 */
}
.hexIn{
  position: absolute;
  width:96%;
  padding-bottom: 110.851%; /* =  width / sin(60) */
  margin:0 2%;
  overflow: hidden;
  visibility: hidden;
  outline:1px solid transparent; /* fix for jagged edges in FF on hover transition */
  -webkit-transform: rotate3d(0,0,1,-60deg) skewY(30deg);
      -ms-transform: rotate3d(0,0,1,-60deg) skewY(30deg);
          transform: rotate3d(0,0,1,-60deg) skewY(30deg);
}
.hexIn * {
  position: absolute;
  visibility: visible;
  outline:1px solid transparent; /* fix for jagged edges in FF on hover transition */
}
.hexLink {
    display:block;
    width: 100%;
    height: 100%;
    text-align: center;
    color: #fff;
    overflow: hidden;
    -webkit-transform: skewY(-30deg) rotate3d(0,0,1,60deg);
        -ms-transform: skewY(-30deg) rotate3d(0,0,1,60deg);
            transform: skewY(-30deg) rotate3d(0,0,1,60deg);
}

/*** HEX CONTENT **********************************************************************/
.hex img {
  left: -100%;
  right: -100%;
  width: auto;
  height: 100%;
  margin: 0 auto;
  object-fit: cover;
  -webkit-transform: rotate3d(0,0,0,0deg);
      -ms-transform: rotate3d(0,0,0,0deg);
          transform: rotate3d(0,0,0,0deg);
}

.hex h1, .hex p {
  width: 100%;
  padding: 5%;
  box-sizing:border-box;
  /*background-color: rgba(0, 128, 128, 0.8);*/
  background-color: rgba(137, 189, 33,0.8);
  font-weight: 300;
  -webkit-transition:  -webkit-transform .2s ease-out, opacity .3s ease-out;
          transition:          transform .2s ease-out, opacity .3s ease-out;


}
.hex h1 {
  color: #fff;
  font-weight: 600;
  bottom: 50%;
  padding-top:50%;
  font-size: 1.5em;
  z-index: 1;
  -webkit-transform:translate3d(0,-100%,0);
      -ms-transform:translate3d(0,-100%,0);
          transform:translate3d(0,-100%,0);

}
.hex h1::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 45%;
  width: 10%;
  text-align: center;
  border-bottom: 1px solid #fff;
}
.hex p {
  color: #fff;
  font-weight: 600;
  top: 50%;
  padding-bottom:50%;
  -webkit-transform:translate3d(0,100%,0);
      -ms-transform:translate3d(0,100%,0);
          transform:translate3d(0,100%,0);
}


/*** HOVER EFFECT  **********************************************************************/
.hexLink:hover h1, .hexLink:focus h1,
.hexLink:hover p, .hexLink:focus p{
  -webkit-transform:translate3d(0,0,0);
      -ms-transform:translate3d(0,0,0);
          transform:translate3d(0,0,0);
}

/*** HEXAGON SIZING AND EVEN ROW INDENTATION *****************************************************************/
@media (min-width:1201px) { /* <- 5-4  hexagons per row */
  #hexGrid{
    padding-bottom: 5.5%
  }
  .hex {
    width: 25%; /* = 100 / 4 */
  }
  .hex:nth-child(7n+5){ /* first hexagon of even rows */
    margin-left:12.5%;  /* = width of .hex / 2  to indent even rows */
  }
}

@media (max-width: 1200px) and (min-width:901px) { /* <- 4-3  hexagons per row */
  #hexGrid{
    padding-bottom: 7.4%
  }
  .hex {
    width: 33.333%; /* = 100 / 3 */
  }
  .hex:nth-child(5n+4){ /* first hexagon of even rows */
    margin-left:16.666%;  /* = width of .hex / 2  to indent even rows */
  }
}

@media (max-width: 900px) and (min-width:601px) { /* <- 3-2  hexagons per row */
  #hexGrid{
    padding-bottom: 7.4%
  }
  .hex {
    width: 33.333%; /* = 100 / 3 */
  }
  .hex:nth-child(5n+4){ /* first hexagon of even rows */
    margin-left:16.666%;  /* = width of .hex / 2  to indent even rows */
  }
}

@media (max-width: 600px) { /* <- 2-1  hexagons per row */
  #hexGrid{
    padding-bottom: 11.2%
  }
  .hex {
    width: 50%; /* = 100 / 3 */
  }
  .hex:nth-child(3n+3){ /* first hexagon of even rows */
    margin-left:25%;  /* = width of .hex / 2  to indent even rows */
  }
}

@media (max-width: 400px) {
    #hexGrid {
        font-size: 13px;
    }
}

html

<section class="margin-1">

  <div class="container">
    <div class="row">
      <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2">
        <p class="text-center"><img class="theme_icon text-center" src="<?php bloginfo('stylesheet_directory'); ?>/assets/img/Signal-Logo-only.png" data-aos="fade-up" data-aos-delay="400"></p>
        <h2 class="heading3 text-center fadeInUpSmall grad-border-bottom mb-5">Content Marketing</h2>
      </div><!-- close col -->
    </div>
  </div>


  <ul id="hexGrid">
    
    <li class="hex">
      <div class="hexIn">
        <a class="hexLink" href="#">
          <img src="https://farm9.staticflickr.com/8461/8048823381_0fbc2d8efb.jpg" alt="" />
          <h1>This is a title</h1>
          <p>Some sample text about the article this hexagon leads to</p>
        </a>
      </div>
    </li>

    <li class="hex">
      <div class="hexIn">
        <a class="hexLink" href="#">
          <img src="https://farm5.staticflickr.com/4144/5053682635_b348b24698.jpg" alt="" />
          <h1>This is a title</h1>
          <p>Some sample text about the article this hexagon leads to</p>
        </a>
      </div>
    </li>

    <li class="hex">
      <div class="hexIn">
        <a class="hexLink" href="#">
          <img src="https://farm3.staticflickr.com/2827/10384422264_d9c7299146.jpg" alt="" />
          <h1>This is a title</h1>
          <p>Some sample text about the article this hexagon leads to</p>
        </a>
      </div>
    </li>

    <li class="hex">
      <div class="hexIn">
        <a class="hexLink" href="#">
          <img src="https://farm7.staticflickr.com/6217/6216951796_e50778255c.jpg" alt="" />
          <h1>This is a title</h1>
          <p>Some sample text about the article this hexagon leads to</p>
        </a>
      </div>
    </li>

    <li class="hex">
      <div class="hexIn">
        <a class="hexLink" href="#">
          <img src="https://farm7.staticflickr.com/6083/6055581292_d94c2d90e3.jpg" alt="" />
          <h1>This is a title</h1>
          <p>Some sample text about the article this hexagon leads to</p>
        </a>
      </div>
    </li>

    <li class="hex">
      <div class="hexIn">
        <a class="hexLink" href="#">
          <img src="https://farm3.staticflickr.com/2827/10384422264_d9c7299146.jpg" alt="" />
          <h1>This is a title</h1>
          <p>Some sample text about the article this hexagon leads to</p>
        </a>
      </div>
    </li>

    <li class="hex">
      <div class="hexIn">
        <a class="hexLink" href="#">
          <img src="https://farm8.staticflickr.com/7187/6895047173_d4b1a0d798.jpg" alt="" />
          <h1>This is a title</h1>
          <p>Some sample text about the article this hexagon leads to</p>
        </a>
      </div>
    </li>

    <li class="hex">
      <div class="hexIn">
        <a class="hexLink" href="#">
          <img src="https://farm4.staticflickr.com/3766/12953056854_b8cdf14f21.jpg" alt="" />
          <h1>This is a title</h1>
          <p>Some sample text about the article this hexagon leads to</p>
        </a>
      </div>
    </li>

    <li class="hex">
      <div class="hexIn">
        <a class="hexLink" href="#">
          <img src="https://farm7.staticflickr.com/6139/5986939269_10721b8017.jpg" alt="" />
          <h1>This is a title</h1>
          <p>Some sample text about the article this hexagon leads to</p>
        </a>
      </div>
    </li>

    <li class="hex">
      <div class="hexIn">
        <a class="hexLink" href="#">
          <img src="https://farm8.staticflickr.com/7163/6822904141_50277565c3.jpg" alt="" />
          <h1>This is a title</h1>
          <p>Some sample text about the article this hexagon leads to</p>
        </a>
      </div>
    </li>

    <li class="hex">
      <div class="hexIn">
        <a class="hexLink" href="#">
          <img src="https://farm4.staticflickr.com/3771/13199704015_72aa535bd7.jpg" alt="" />
          <h1>This is a title</h1>
          <p>Some sample text about the article this hexagon leads to</p>
        </a>
      </div>
    </li>

    <li class="hex">
      <div class="hexIn">
        <a class="hexLink" href="#">
          <img src="https://farm7.staticflickr.com/6083/6055581292_d94c2d90e3.jpg" alt="" />
          <h1>This is a title</h1>
          <p>Some sample text about the article this hexagon leads to</p>
        </a>
      </div>
    </li>

    <li class="hex">
      <div class="hexIn">
        <a class="hexLink" href="#">
          <img src="https://farm8.staticflickr.com/7187/6895047173_d4b1a0d798.jpg" alt="" />
          <h1>This is a title</h1>
          <p>Some sample text about the article this hexagon leads to</p>
        </a>
      </div>
    </li>
   
    <li class="hex">
      <div class="hexIn">
        <a class="hexLink" href="#">
          <img src="https://farm7.staticflickr.com/6083/6055581292_d94c2d90e3.jpg" alt="" />
          <h1>This is a title</h1>
          <p>Some sample text about the article this hexagon leads to</p>
        </a>
      </div>
    </li>
    
  </ul>

  <!-- <a id="fork" target="_blank" href="https://github.com/web-tiki/responsive-grid-of-hexagons">Fork on GitHub</a> -->

</section>

Any ideas what I’m doing wrong?

1 Like

.hex h1 and .hex p are getting a margin (inspect element says it’s from bootstrap)

If you add a margin: 0 to your css, it removes the gap.

.hex h1, .hex p {
  width: 100%;
  padding: 5%;
  margin: 0;
  box-sizing:border-box;
  /*background-color: rgba(0, 128, 128, 0.8);*/
  background-color: rgba(137, 189, 33,0.8);
  font-weight: 300;
  -webkit-transition:  -webkit-transform .2s ease-out, opacity .3s ease-out;
          transition:          transform .2s ease-out, opacity .3s ease-out;
}
2 Likes

Thanks Dave!

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.