Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to make CSS triangles / arrows that aren't your typical right angled triangles with a gradient applied?

I know that to create a basic arrow in CSS I can do this:

<div class="arrow-button">
    <span class="arrow-tip-container">
         <span class="arrow-tip"></span>
    </span>
</div>

Then all I'll have to do is rotate and position the container then fill the arrow-tip and BAM! there;s a sweet arrow: http://jsfiddle.net/uF69S/

However, I want an arrow where the tip is effectively a 120° angle, so is it possible to achieve this effect using CSS transforms or two different containers? Maybe a skew and a rotate?

I would like to create this arrow:

------------\
|            \
|            /
------------/

Notice that the arrowhead is not 90°.

NOTE: I am aware that border triangle could be used to make any angle of triangle, however they do not support gradients in Firefox, Opera or IE, whereas Firefox, Opera and IE can support transforms (in one way or another).

like image 749
Jai Avatar asked Dec 20 '12 15:12

Jai


People also ask

How do you make an arrow shape in CSS?

Arrows. To create a simple arrow without a tail, make a box with a width and height, border, as well as zero left and top borders. To make an up arrow, add the transform: rotate(225deg); property, and to make a down arrow, add the transform: rotate(45deg); property to rotate the arrow to 225 and 45 degrees respectively ...

How do CSS triangles work?

The idea is a box with zero width and height. The actual width and height of the arrow is determined by the width of the border. In an up arrow, for example, the bottom border is colored while the left and right are transparent, which forms the triangle.


2 Answers

You can use skew for making triangle of 120 degree like this:

.arrow-tip {
    display:block;
    width:50px;
    height:50px;
    margin:0 0 0 -20px;
    -webkit-transform:rotate(45deg) skew(20deg,20deg);
 }

Also : http://jsfiddle.net/95Xq8/

like image 133
ramshinde1992 Avatar answered Oct 14 '22 18:10

ramshinde1992


This might be a start:

HTML:

<div>▲</div>​

CSS:

div {
  font-size: 46px;
  -webkit-transform: scaleY(.3);
}​

View it on JSFiddle

like image 44
jamesplease Avatar answered Oct 14 '22 19:10

jamesplease