I have multiple hexagons in a grid. I'm trying to have the grid items (hexagons) height and width responsive to the layout. Like as you can see in the jsfiddle they are overflowing from the grid container. Is there any way I could make the height and width fix relative to its container like whatever the layout is, they remain the same?
https://jsfiddle.net/gv5wc12x/3/
.home {
width: 100%;
height: 100vh;
background-color: rgb(123, 158, 158);
}
.hex-container {
max-width: 1000px;
margin: 0px auto;
margin-bottom: 100px;
display: grid;
grid-template-columns: repeat(9, 1fr);
grid-auto-rows: 205px;
grid-gap: 2px;
filter: drop-shadow(0px 0px 8px rgba(247, 247, 247, 0.9));
}
.hexagon {
z-index: 0;
display: flex;
width: 250px;
height: 270px;
position: relative;
clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}
.hexagon:first-child {
grid-row-start: 1;
grid-column: 2 / span 2;
background-color: #003366;
}
.hexagon:nth-child(2) {
grid-row-start: 1;
grid-column: 4 / span 2;
background-color: #87cefa;
}
.hexagon:nth-child(3) {
grid-row-start: 1;
grid-column: 6 / span 2;
background-color: #f5f5f5;
}
.hexagon:nth-child(4) {
grid-row-start: 2;
grid-column: 3 / span 2;
background-color: #f5f5f5;
}
.hexagon:nth-child(5) {
grid-row-start: 2;
grid-column: 5 / span 2;
background-color: #003366;
}
<div class="home">
<div class="hex-container">
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
</div>
</div>
Please any help would be appreciated.