Question

I've found plenty of tutorials for creating Trapezoids using CSS3 but I am looking to create a four sided shape where none of the side are parallel (trapezium) like the one in the picture below.

enter image description here

Is this possible?

Was it helpful?

Solution 2

you could do this "by hand" html:

<canvas id="polygon" />

javascript

var polygon = document.getElementById('polygon').getContext('2d');
polygon.fillStyle = '#f00';
polygon.beginPath();
polygon.moveTo(0, 0);
polygon.lineTo(90,50);
polygon.lineTo(70, 70);
polygon.lineTo(0, 90);
polygon.closePath();
polygon.fill();

this doesn't make shure it's convex and it has no parallel lines. You have to put in the correct coordinates.

Fiddle: http://jsfiddle.net/8t4rZ/

OTHER TIPS

Okay..Sorry for being late. Here's my answer:

Fiddle: http://jsfiddle.net/fELER/1/

CSS:

#up-triangle {
   width: 0; 
   height: 0; 
   border-bottom: 200px solid yellow; 
   border-left: 100px solid transparent; 
   border-right: 100px solid transparent; 
}

#right-triangle {
   position:absolute;
   top: 10px;
   left:175px;
   width: 50px; 
   height: 100px; 
   border-style: solid;
   border-width: 100px 0 0 300px; 
   border-color: transparent transparent transparent yellow;
   -webkit-transform: skew(29deg); 
   -moz-transform: skew(29deg); 
   -o-transform: skew(29deg);
   transform: skew(29deg);
}

HTML:

<div id="up-triangle"></div>
<div id="right-triangle"></div>

Some useful links: http://www.css3shapes.com/

http://apps.eky.hk/css-triangle-generator/

#box {
    border-bottom: 100px solid red;
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    height: 0;
    width: 100px;
}

CSS trapezoid

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top