JSFiddle - React, Tailwind, and code Playground
by DugSohn
HTML
<div class="hexagon hexagon2"><div class="hexagon-in1"><div class="hexagon-in2"></div></div></div>
CSS
BODY {
padding:200px
}
.hexagon {
overflow: hidden;
visibility: hidden;
-webkit-transform: rotate(120deg);
-moz-transform: rotate(120deg);
-ms-transform: rotate(120deg);
-o-transform: rotate(120deg);
transform: rotate(120deg);
cursor: pointer;
background-color: blue;
}
.hexagon-in1 {
overflow: hidden;
width: 100%;
height: 100%;
-webkit-transform: rotate(-60deg);
-moz-transform: rotate(-60deg);
-ms-transform: rotate(-60deg);
-o-transform: rotate(-60deg);
transform: rotate(-60deg);
}
.hexagon-in2 {
width: 100%;
height: 100%;
background-color: blue;
background-repeat: no-repeat;
background-position: 50%;
background-image: url(https://www.webfx.com/blog/images/cdn.designinstruct.com/files/137-shipping_package_box/step03a.jpg);
visibility: visible;
-webkit-transform: rotate(-60deg);
-moz-transform: rotate(-60deg);
-ms-transform: rotate(-60deg);
-o-transform: rotate(-60deg);
transform: rotate(-60deg);
}
.hexagon1 {
width: 400px;
height: 200px;
margin: 0 0 0 -80px;
}
.hexagon2 {
background-color: blue;
width: 200px;
height: 400px;
margin: -80px 0 0 20px;
}
.dodecagon {
width: 200px;
height: 200px;
margin: -80px 0 0 20px;
}
JavaScript
// And some more complex polygons!
// http://kizu.github.com/Polygons/
// Fork them on github: https://github.com/kizu/Polygons/