-2

I want o adjust button sizes according to screen resolutions,on smaller devices screens as on well as on PC screen

5 Answers5

4

The other answers are correct, but they are not equilateral like the OP requests. Try this instead:

http://jsfiddle.net/mt2yA/

<a href='#'>
  <div class='tri-button'></div>
</a>

.tri-button {
  width: 0;
  height: 0;
  border-left: 50px solid transparent;
  border-right: 50px solid transparent;
  border-bottom: 80px solid black;
}
Matthew R.
  • 4,332
  • 1
  • 24
  • 39
2
<a href='#'>
  <div class='tri-button'></div>
</a>

.tri-button {
  width: 0;
  height: 0;
  border-left: 50px solid transparent;
  border-right: 50px solid transparent;
  border-bottom: 50px solid black;
}

Demo

brbcoding
  • 13,378
  • 2
  • 37
  • 51
1

http://css-tricks.com/snippets/css/css-triangle/ makes it extremely simple.

HTML:

<div class="arrow-up"></div>
<div class="arrow-down"></div>
<div class="arrow-left"></div>
<div class="arrow-right"></div>

CSS:

.arrow-up {
    width: 0; 
    height: 0; 
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;

    border-bottom: 5px solid black;
}

.arrow-down {
    width: 0; 
    height: 0; 
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;

    border-top: 20px solid #f00;
}

.arrow-right {
    width: 0; 
    height: 0; 
    border-top: 60px solid transparent;
    border-bottom: 60px solid transparent;

    border-left: 60px solid green;
}

.arrow-left {
    width: 0; 
    height: 0; 
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent; 
    border-right:10px solid blue; 
}
Zach
  • 442
  • 1
  • 5
  • 12
1

Here is JSBin with equilateral triangle

<a href='#'>
    <div class="triangle"></div>
</a>

In your CSS

.triangle {
    width: 0; 
    height: 0; 
    border-left: 40px solid transparent;
    border-right: 40px solid transparent;
    border-bottom: 60px solid blue;
}
Naveen Kumar Alone
  • 7,536
  • 5
  • 36
  • 57
0

If I would have to do this I suppose that the best way is mapping an image. You have to do a simple image with triangle shape and transparent background and then using a map you could define an area with this shape (only with three coordinates). You can add a href attribute to the area and use it as a link.

<img src="triangle.png" usemap="#mapa" width="100" height="100"/>
<map name="mapa">
<area shape="poly" coords="0,100,50,0,100,100,0,100" href="">

You would be generating a button with triangle shape. You can add to this area some functions of js if you want too.