This will be a triangle pointed towards the top. Don't specify the border to the side where you need it to be pointed.
The above is an equilateral triangle. Remove border-left to make it a right-angled triangle.
回答5:
Consider using the element. I build a simple triangle on jsfiddle - nothing fancy, yet.
var canvas = document.getElementById('myCanvas'); var context = canvas.getContext('2d'); context.beginPath(); context.moveTo(10, 0); context.lineTo(20, 20); context.lineTo(0, 20); context.closePath(); context.fill();
回答6:
You can use the method I described here : How does this CSS triangle shape work? with a rotated pseudo element. You can then add a border to the rotated pseudo element to create the effect you are looking for.
You can also use this technique to display the triangle with borders over an image, gradient or any non plain backgrounds :