I've constructed a grid of hexagons in HTML and CSS and I'm trying to get a linear gradient to span across the entire grid. The HTML and CSS I'm using for the hex grid is below:
.hex {
float: left;
margin-right: -26px;
margin-bottom: -50px;
}
.hex .left {
float: left;
width: 0;
border-right: 30px solid #6C6;
border-top: 52px solid transparent;
border-bottom: 52px solid transparent;
}
.hex .middle {
float: left;
width: 60px;
height: 104px;
background: #6C6;
}
.hex .right {
float: left;
width: 0;
border-left: 30px solid #6C6;
border-top: 52px solid transparent;
border-bottom: 52px solid transparent;
}
.hex-row {
clear: left;
}
.hex.even {
margin-top: 53px;
}
.top-hex {
margin-left: 95px;
}
<div class="col hex-gradient">
<div class="hex-row">
<div class="hex top-hex">
<div class="left"></div>
<div class="middle"></div>
<div class="right"></div>
</div>
</div>
<div class="hex-row">
<div class="hex">
<div class="left"></div>
<div class="middle"></div>
<div class="right"></div>
</div>
<div class="hex even">
<div class="left"></div>
<div class="middle"></div>
<div class="right"></div>
</div>
<div class="hex">
<div class="left"></div>
<div class="middle"></div>
<div class="right"></div>
</div>
</div>
<div class="hex-row">
<div class="hex">
<div class="left"></div>
<div class="middle"></div>
<div class="right"></div>
</div>
<div class="hex even">
<div class="left"></div>
<div class="middle"></div>
<div class="right"></div>
</div>
<div class="hex">
<div class="left"></div>
<div class="middle"></div>
<div class="right"></div>
</div>
</div>
</div>
I tried looking around SO for a solution and came across the Multiple.js method. Which I attempted to apply:
.hex-gradient {
background-image: linear-gradient(white, black);
background-size: cover;
background-position: center;
background-attachment: fixed; /* <- here it is */
width: 100px;
height: 100px;
}
However this didn't work as you see here:
Is there any way I can apply the black and white gradient to just the hexagons?
