JSFiddle - React, Tailwind, and code Playground
HTML
<svg id="mySVG" height="40%" width="40%">
<polygon id="ok" points="50,50 150,50 150,150 50,150" />
<polygon id="up" points="0,0 200,0 150,50 50,50" />
<polygon id="right" points="200,0 200,200 150,150 150,50" />
<polygon id="down" points="0,200 50,150 150,150 200,200" />
<polygon id="left" points="0,0 50,50 50,150 0,200" />
</svg>
CSS
svg {
background:#000000;
}
#ok {
fill: red;
}
#up {
fill: blue;
}
#down {
fill: green;
}
#right {
fill: yellow;
}
#left {
fill: orange;
}
polygon:hover {opacity:0.75;}
JavaScript
function resizeButtons() {
// get the width
var w = $("#mySVG").width();
// make it squared
$("#mySVG").height(w);
// recalculate the position of each polygon
$("#ok").attr("points", w * 0.25 + "," + w * 0.25 + " " + w * 0.75 + "," + w * 0.25 + " " + w * 0.75 + "," + w * 0.75 + " " + w * 0.25 + "," + w * 0.75);
$("#up").attr("points", "0,0 " + w + ",0 " + w * 0.75 + "," + w * 0.25 + " " + w * 0.25 + "," + w * 0.25);
$("#right").attr("points", w + ",0 " + w + "," + w + " " + w * 0.75 + "," + w * 0.75 + " " + w * 0.75 + "," + w * 0.25);
$("#down").attr("points", "0," + w + " " + w * 0.25 + "," + w * 0.75 + " " + w * 0.75 + "," + w * 0.75 + " " + w + "," + w);
$("#left").attr("points", "0,0 " + w * 0.25 + "," + w * 0.25 + " " + w * 0.25 + "," + w * 0.75 + " 0," + w);
}
$(window).resize(function () {
resizeButtons();
});
$(document).ready(function() {
resizeButtons();
$("polygon").on("click", function() {
alert($(this).attr("id"));
});
});