If you want to play around with border-size
, width
and height
and see how those can create different shapes, try this:
const sizes = [32, 32, 32, 32];_x000D_
const triangle = document.getElementById('triangle');_x000D_
_x000D_
function update({ target }) {_x000D_
let index = null;_x000D_
_x000D_
if (target) {_x000D_
index = parseInt(target.id);_x000D_
_x000D_
if (!isNaN(index)) {_x000D_
sizes[index] = target.value;_x000D_
}_x000D_
}_x000D_
_x000D_
window.requestAnimationFrame(() => {_x000D_
triangle.style.borderWidth = sizes.map(size => `${ size }px`).join(' ');_x000D_
_x000D_
if (isNaN(index)) {_x000D_
triangle.style[target.id] = `${ target.value }px`;_x000D_
}_x000D_
});_x000D_
}_x000D_
_x000D_
document.querySelectorAll('input').forEach(input => {_x000D_
input.oninput = update;_x000D_
});_x000D_
_x000D_
update({});
_x000D_
body {_x000D_
margin: 0;_x000D_
min-height: 100vh;_x000D_
display: flex;_x000D_
justify-content: center;_x000D_
align-items: center;_x000D_
overflow: hidden;_x000D_
}_x000D_
_x000D_
#triangle {_x000D_
border-style: solid;_x000D_
border-color: yellow magenta blue black;_x000D_
background: cyan;_x000D_
height: 0px;_x000D_
width: 0px;_x000D_
}_x000D_
_x000D_
#controls {_x000D_
position: fixed;_x000D_
bottom: 0;_x000D_
left: 0;_x000D_
right: 0;_x000D_
background: white;_x000D_
display: flex;_x000D_
box-shadow: 0 0 32px rgba(0, 0, 0, .125);_x000D_
}_x000D_
_x000D_
#controls > div {_x000D_
position: relative;_x000D_
width: 25%;_x000D_
padding: 8px;_x000D_
box-sizing: border-box;_x000D_
display: flex;_x000D_
}_x000D_
_x000D_
input {_x000D_
margin: 0;_x000D_
width: 100%;_x000D_
position: relative;_x000D_
}
_x000D_
<div id="triangle" style="border-width: 32px 32px 32px 32px;"></div>_x000D_
_x000D_
<div id="controls">_x000D_
<div><input type="range" min="0" max="128" value="32" id="0" /></div>_x000D_
<div><input type="range" min="0" max="128" value="32" id="1" /></div>_x000D_
<div><input type="range" min="0" max="128" value="32" id="2" /></div>_x000D_
<div><input type="range" min="0" max="128" value="32" id="3" /></div>_x000D_
<div><input type="range" min="0" max="128" value="0" id="width" /></div>_x000D_
<div><input type="range" min="0" max="128" value="0" id="height" /></div>_x000D_
</div>
_x000D_