I want o adjust button sizes according to screen resolutions,on smaller devices screens as on well as on PC screen
Asked
Active
Viewed 512 times
-2
-
Do you specifically need the – AdityaSaxena Aug 16 '13 at 14:10
-
http://stackoverflow.com/questions/7073484/how-does-this-css-triangle-shape-work?rq=1 – j08691 Aug 16 '13 at 14:16
-
PLease view my posted answer and accept it as answer for close this issue. http://stackoverflow.com/questions/18275323/how-to-make-trialngular-shaped-button-in-css/18275451#18275451 ThanQ :) – Naveen Kumar Alone Aug 17 '13 at 07:08
5 Answers
4
The other answers are correct, but they are not equilateral like the OP requests. Try this instead:
<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
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.

Tomas Timinskas
- 73
- 1
- 6