/ Published in: CSS
This implements a pure CSS technique for creating triangles. A great practical usage of this is Web 2.0 style comment/speach bubbles. Demo: http://www.adamcoulombe.info/lab/css/comment-bubbles.html
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Pure CSS Web 2.0 Comment Bubbles</title> <style type="text/css"> body { font:20px Arial, Helvetica, sans-serif; } .bubble1 { overflow:hidden; margin:20px; } .bubble1 .speach { background-color:#000000; color:#FFFFFF; padding:20px; } .bubble1 .arrow{ float:right; margin-right:15px; width:0; height:0; border-left: 10px solid transparent; border-right: 10px solid transparent; border-top: 10px solid #000000; border-bottom: 0; } .bubble2 { overflow:hidden; margin:20px; } .bubble2 .speach { background-color:#d9ecfb; color:#486175; padding:20px; } .bubble2 .arrow{ float:right; margin-right:15px; width:0; height:0; border-left: 15px solid transparent; border-right: 15px solid #d9ecfb; border-bottom: 15px solid transparent; border-top: 0; } .bubble3 { overflow:hidden; margin:20px; position:relative; } .bubble3 .speach { background-color:#ebe5d2; color:#7b6f49; padding:20px; margin-left:15px; } .bubble3 .arrow{ width:0; height:0; border-left: 0px solid transparent; border-right: 15px solid #ebe5d2; border-bottom: 15px solid transparent; border-top: 0; position:absolute; left:0px; top:10px; } .bubble4 { overflow:hidden; margin:20px; position:relative; } .bubble4 .speach { background-color:#dfebd2; color:#526340; padding:20px; margin-right:15px; } .bubble4 .arrow{ width:0; height:0; border-right: 0px solid transparent; border-left: 15px solid #dfebd2; border-top: 15px solid transparent; border-bottom: 0; position:absolute; right:0px; bottom:10px; } </style> </head> <body> <div class="bubble bubble1"> <div class="speach">Lorem ipsum dolor sit amet, consectetur adipiscing elit. </div> <div class="arrow"></div> </div> <div class="bubble bubble2"> <div class="speach">Lorem ipsum dolor sit amet, consectetur adipiscing elit. </div> <div class="arrow"></div> </div> <div class="bubble bubble3"> <div class="speach">Lorem ipsum dolor sit amet, consectetur adipiscing elit. </div> <div class="arrow"></div> </div> <div class="bubble bubble4"> <div class="speach">Lorem ipsum dolor sit amet, consectetur adipiscing elit. </div> <div class="arrow"></div> </div> </body> </html>
URL: http://www.adamcoulombe.info/lab/css/comment-bubbles.html