I love the creativity that results from CSS' limitations (or, arguably, its flexibility). Neat trick.<p>It took me a moment to realize exactly what was going on to make this work. For those interested: borders are styled in such a way that they angle toward the edges if the border is large enough:<p><pre><code> \ /
/ \
</code></pre>
That gives you four "V"s to work with. Therefore, to create the arrow, you simply need to hide all but the appropriate border. The border around the arrow is accomplished by underlaying another "V".
This is the way to do it, until the graphics guy wants the box to have a drop shadow. The pseudo elements' shadow is square, so your options are either to hope that nobody notices that the arrow doesn't have a shadow (like in this example), or to use an image for the arrow.
I really suck at CSS. I mean, I really suck. It takes me forever to accomplish the smallest things. I love these sites that keep popping up that generate CSS for cool little effects.<p>Thanks!
This is great so long as you don't still have to support IE7.<p><a href="http://css-tricks.com/browser-support-pseudo-elements/" rel="nofollow">http://css-tricks.com/browser-support-pseudo-elements/</a>
That's so funny... just yesterday I built my own sass mixin to create custom triangles to do the little arrow pointer on a dialog box like this. Two triangles (border color and background color) with an offset. I toyed with using :before and/or :after to create the second background-color triangle, but the specs said you could only do text or an image so I didn't even try to make the triangle. My version required something like <div class="arrow arrow-left"><div class="arrow-inner arrow-inner-left"></div></div>. This is so much more semantic, elegant, and awesome. I love it!
I made a bunch of this kind (and more complex) speech bubbles a couple of years ago: <a href="http://nicolasgallagher.com/pure-css-speech-bubbles/demo/" rel="nofollow">http://nicolasgallagher.com/pure-css-speech-bubbles/demo/</a><p>This is a nice little tool to help automate the production of the code for simple ones.
Because the shadow seems to be setup so that the light source is at the top, when you move the arrow to any other position, the lack of shadow under the arrow becomes noticeable.<p>If the light source moved along with the triangle, no shadow under the arrow would be required (imo).
I've been writing CSS for a couple of years now and it took me like 10 minutes to understand why this is even working.<p>I already feel sorry for anyone that will be debugging this mess.