Voice bubbles are a very popular effect. On many social websites, you can see that comments use this effect to achieve this, which is very attractive to visitors, however, I found that many of these effects depend on HTML or JavaScript for implementation. This tutorial includes incremental enhancement of bubble effects created using CSS 2.1 and CSS3 in various forms. It is built in pure CSS3 without images and JavaScript. It can be applied to your existing HTML.
Demonstration: pure CSS bubbles
Supported: Firefox 3.5 +, Safari 4 +, Chrome 4 +, Opera 10 +, IE8 + ..
Progressive enhancement and pseudo elements
Simple
<div>Content</div>
Or <P> Content </p> code
You can produce a speech bubble, for example:
Add a child element, such<blockquote><p>Quote</p></blockquote>
You can even produce a speech bubble, such:
You can build your own element code based on your own needs. The key is to use
:before
And:after
Pseudo elements generate basic shapes.
Apply the CSS3 attribute, as shown in figureBorder-radius attributes
Andtransform
You can create more complex shapes and orientations.
Sample Code
This is an example of how to create a basic speech bubble shape. For further examples, you can view the demo page and CSS file,
1 /* Bubble with an isoceles triangle 2 ------------------------------------------ */ 3 4 .triangle-isosceles { 5 position:relative; 6 padding:15px; 7 margin:1em 0 3em; 8 color:#000; 9 background:#f3961c;10 11 /* css3 */12 -moz-border-radius:10px;13 -webkit-border-radius:10px;14 border-radius:10px;15 background:-moz-linear-gradient(top, #f9d835, #f3961c);16 background:linear-gradient(top, #f9d835, #f3961c);17 }18 19 /* creates triangle */20 .triangle-isosceles:after {21 content:"";22 display:block; /* reduce the damage in FF3.0 */23 position:absolute;24 bottom:-15px;25 left:50px;26 width:0;27 border-width:15px 15px 0;28 border-style:solid;29 border-color:#f3961c transparent;30 }
Notes for gradual enhancement
This method is progressively enhanced. We see the Style Layer: "simple color box, rounded rectangle or circular gradient background. These browser styles can be displayed.
IE6 and IE7 do not support CSS2.1 pseudo elements, and all: before AND: after declarations are ignored. They do not have any enhancement, but keep the basic usage habits...
Warning about Firefox 3.0
Although Firefox 3.0 supports CSS2.1 pseudo elements, it does not support location.
123
Link to this article: cutting-edge design recommendations-very popular speech bubble effects created by pure CSS