Do not set the initial height of the DIV to 0, so you can determine the height of the client div and set the width of the border. And then set the height to 0:
.trapezoid { width: 80px; border-bottom: 80px solid blue; border-left: 40px solid transparent; } document.getElementById('xMyDiv').style.borderBottomWidth = document.getElementById('xMyDiv').clientHeight + 'px'; document.getElementById('xMyDiv').style.height = '0px';
Here is a working fiddle: http://jsfiddle.net/uE6x4/4/
source share