6 ms·
It's just a hack. If you want to create a triangle you'll either draw it on a CANVAS or use SVG. You just cant for instance, put a text in a triangle easily wit
by camus 13y ago
It's just a hack. If you want to create a triangle you'll either draw it on a CANVAS or use SVG. You just cant for instance, put a text in a triangle easily with CSS today(at least in a cross-browser way).
- annnnd 13y agoSure you can - you just write it in another DIV, positioned above your triangle. Or did I misunderstand you? The beauty for me is not in the hack itself though, it is in the way it is presented - I adore the simplicity of this approach. Kudos!
- chavesn 13y agoWell, then the text isn't really "in" the triangle, is it? Leading you to rely on further hacks to make sure the text stays in the triangle with a nice padding, correct wrapping, and all the other features you get when text is really inside a container.
- jeremiep 13y agoCould always do <div class="triangle"><span>Hello</span></div> where the div has position: relative and the span has position: absolute. Should work everywhere too.
- chavesn 13y agoYes, that's how you'd get a box to appear over the triangle, but it doesn't really solve any of the containment issues. Example: http://jsfiddle.net/9pMJS/ http://jsfiddle.net/9pMJS/
- gren 13y agoUsually I use a :after or :before for the triangle. #box { position: relative } #box:after {position: absolute; top: -10px; left: 45%; ... }