Speech balloon with pure CSS--One step further
Many of us want to add cool features to our websites to make our websites user friendly ad more attractive. Especially in Web2.0 era. Today we are talking about adding speech balloon feature to our webpage so that we can display beautiful help windows while users mouse over some help icons on our page.
First, let me introduce one post written by Umar Ashfaq named "How to create a speech balloon with pure CSS". He also explains how this works. You can also refer Magic CSS shape for more information. This is a brilliant idea. He uses the border property to construct the triangle without using any images. We all know that use of image is costly. This is really a good example you can use in you design.
But there is one small issue with it, this example requires the border color of the arrow div and the background color of the balloon div to be the same. Imagine if we want to have a border for the balloon div which has a different color with the div background color, then the arrow div will not have a border which has the same color as the balloon div's border color, this will introduce inconsistency. So how to solve this problem? You get it. We can add one more arrow div. The outer arrow div has the border width one more pixel larger than the inner arrow. div Then these two arrows overlaps, we will then get the arrow which has border effect.
The HTML code will be :
<div class="balloon"><div class="outer_arrow"></div>
<div class="inner_arrow"></div>But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?</div>
The CSS code can be :
Basically, the inner arrow will overlap with the outer arrow and since the inner arrow has a background color of white and the outer arrow has a border of gray. So it looks like there is a one pixel gray color border around the inner arrow. This width can be adjusted accordingly.
Hope this small trick is helpful to you.
Last night I had a dream. In that dream, my boyfriend was shopping with another woman. The first reaction of mine in that dream was to check the source code... The end result is it's still that woman but not me after a long time debugging, so I have to comment out that woman and run the program agai