Question

Firstly here's the fiddle: http://jsfiddle.net/krish7878/kuG6X/3/

I need a css triangle with just a border for a text bubble, the background should be transparent.

Code:

HTML:<div class="arrow-up"> </div>

CSS:

.arrow-up {
  position:absolute;
  top:50px;
  left:5px;
  width: 0;
  height: 0;
  border-left: 0px solid transparent;
  border-right: 42px solid transparent;
  border-top: 42px solid black;
  margin: 10px; 
  -ms-transform: rotate(315deg); /* IE 9 */
  -webkit-transform: rotate(315deg); /* Chrome, Safari, Opera */
  transform: rotate(315deg);
}
Was it helpful?

Solution

Someone already posted a pretty good answer to this question: https://stackoverflow.com/a/18607208/1320911

http://jsfiddle.net/wmDNr/3/

 .triangle { 
     position: relative;
     width: 20px;
     margin-top: 100px;
 }
 .triangle>div { 
     width: 20px;
     height: 2px;
     background: red;
     margin-top: 100px;
 }

 .triangle>div:before {
     content: " ";
     display: block;
     width: 20px;
     height: 2px;
     background: red;
     -webkit-transform: rotate(56deg);
     -moz-transform: rotate(56deg);
     -ms-transform: rotate(56deg);
     transform: rotate(56deg);
     position: absolute;
     top: -8px;
     right: -5px;
 }
 .triangle>div:after {
     content: " ";
     display: block;
     width: 20px;
     height: 2px;
     background: red;
     -webkit-transform: rotate(-56deg);
     -moz-transform: rotate(-56deg);
     -ms-transform: rotate(-56deg);
     transform: rotate(-56deg);
     position: absolute;
     top: -8px;
     left: -5px;
 }

OTHER TIPS

why do you need to use css? It's just bytes. Use the html special geometric shapes for triangles:

Normal Triangle: &#9651;
Right Showing Triangle:  &#9655;  
Down Pointing Triangle: &#9661; 
Left Pointing Triangle: &#9665;

It saves lot of your effort and faster over the Internet.

⚠: Check the Brower Compatibility

Full Geometric Reference: http://www.alanwood.net/unicode/geometric_shapes.html

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