JSFiddle - React, Tailwind, and code Playground

by modernweb

HTML

<div class="hexagon hexagon1">
    <div class="hexagon-in1">
        <div class="hexagon-in2"></div>
    </div>
</div>

<div class="hexagon hexagon2">
    <div class="hexagon-in1">
        <div class="hexagon-in2"></div>
    </div>
</div>

CSS

body {
    padding: 40px;
}

.hexagon {
    overflow: hidden;
    visibility: hidden;
    transform: rotate(120deg);
    cursor: pointer;
}
.hexagon-in1 {
    overflow: hidden;
    width: 100%;
    height: 100%;
    transform: rotate(-60deg);
}
.hexagon-in2 {
    width: 100%;
    height: 100%;
    background-repeat: no-repeat;
    background-position: 50%;
    background-image: url(http://placekitten.com/241/241);
    visibility: visible;
    transform: rotate(-60deg);
}

.hexagon1 {
    width: 400px;
    height: 200px;
    margin: 0 0 0 -80px;
}

.hexagon2 {
    width: 200px;
    height: 400px;
    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/