I am faced with a challenge of arranging 127 divs to form a hexagon shape similar to the example below:
for (i = 1; i <= 127; i++) {
var div = document.createElement('div');
document.getElementsByTagName('body')[0].appendChild(div);
}
body {
margin-left: 200px;
}
div {
width: 40px;
height: 30px;
display: block;
background: green;
cursor: pointer;
float: left;
}
/* Additional CSS rules for alternate colored divs and positioning */
While the first three rows and the last three rows appear as expected, there is a noticeable hole in the rows in between. How can this hole be eliminated?