Pure CSS Speech Bubble

General CSS elements:

.tooltipMask {
	-webkit-border-radius: 15px 15px 15px 15px;
	-moz-border-radius: 15px 15px 15px 15px;
	border-radius: 15px 15px 15px 15px;
	-webkit-box-shadow: 2px 2px 4px #333;  
	-moz-box-shadow: 2px 2px 4px #333;
	box-shadow: 2px 2px 4px #333;
	filter: progid:DXImageTransform.Microsoft.Shadow(color='#969696', Direction=145, Strength=3);
	overflow:hidden;
	width:320px;
	z-index:3;
}

  HTML + CSS for each bubble type: Speech Bubble with bottom-left triangle

Title...
Content...
 
.tooltip-bottom-left {
	position:absolute;
	left:100px;
	margin-top:50px;
}

.tooltip-bottom-left .box-top {
	position: relative;
	-webkit-border-radius: 15px 15px 0px 0px;
	-moz-border-radius: 15px 15px 0px 0px;
	-o-border-radius: 15px 15px 0px 0px;
	border-radius: 15px 15px 0px 0px;
	-khtml-border-radius: 15px 15px 0px 0px;
	background-color:#FF0000;
	padding:10px;
	height:25px;
	width:300px;
	text-align:left;
	color:white;
	z-index:4;
	font-family:Arial, Helvetica, sans-serif;
	font-size:14px;
	float:left;
}

.tooltip-bottom-left .box-bottom {
	float:left;
	position: relative;
	-webkit-border-radius: 0px 0px 15px 15px;
	-moz-border-radius: 0px 0px 15px 15px;
	-o-border-radius: 0px 0px 15px 15px;
	border-radius: 0px 0px 15px 15px;
	-khtml-border-radius: 0px 0px 15px 15px;
	padding:10px;
	min-height:100px;
	width:298px;
	text-align:center;
	color:#222222;
	z-index:5;
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px;
	background: #f7f7e0;
	border:1px solid red;
	border-top:none;
}

.tooltip-bottom-left .triangle {
	position:relative;
	z-index: 3;
}

.tooltip-bottom-left .triangle:before {
	-moz-border-bottom-colors: none;
	-moz-border-left-colors: none;
	-moz-border-right-colors: none;
	-moz-border-top-colors: none;
	-moz-transform: rotate(50deg);
	-webkit-border-bottom-colors: none;
	-webkit-border-left-colors: none;
	-webkit-border-right-colors: none;
	-webkit-border-top-colors: none;
	-webkit-transform: rotate(50deg);
	-o-border-bottom-colors: none;
	-o-border-left-colors: none;
	-o-border-right-colors: none;
	-o-border-top-colors: none;
	-o-transform: rotate(50deg);
	-ms-transform: rotate(50deg);
	border-color: transparent red;
	border-image: none;
	border-style: solid;
	border-width: 20px 30px 70px 0;
	bottom: -50px;
	content: "";
	display: block;
	left: 75px;
	position: absolute;
	width: 0;
	z-index: 3;
}

  Speech Bubble with top-right triangle

Title...
Text blah blah...
 
.tooltip-top-right {
	position:absolute;
	left:500px;
	top:350px;
	margin-top:50px;
}

.tooltip-top-right .box-top {
	position: relative;
	-webkit-border-radius: 15px 15px 0px 0px;
	-moz-border-radius: 15px 15px 0px 0px;
	-o-border-radius: 15px 15px 0px 0px;
	border-radius: 15px 15px 0px 0px;
	-khtml-border-radius: 15px 15px 0px 0px;
	background-color:#FF0000;
	padding:10px;
	height:25px;
	width:300px;
	text-align:left;
	color:white;
	z-index:4;
	font-family:Arial, Helvetica, sans-serif;
	font-size:14px;
	float:left;
}

.tooltip-top-right .box-bottom {
	float:left;
	position: relative;
	-webkit-border-radius: 0px 0px 15px 15px;
	-moz-border-radius: 0px 0px 15px 15px;
	-o-border-radius: 0px 0px 15px 15px;
	border-radius: 0px 0px 15px 15px;
	-khtml-border-radius: 0px 0px 15px 15px;
	padding:10px;
	min-height:100px;
	width:298px;
	text-align:center;
	color:#222222;
	z-index:5;
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px;
	background: #f7f7e0;
	border:1px solid red;
	border-top:none;
}

.tooltip-top-right .triangle {
	position:relative;
	z-index: 3;
}

.tooltip-top-right .triangle:before {
	-moz-border-bottom-colors: none;
	-moz-border-left-colors: none;
	-moz-border-right-colors: none;
	-moz-border-top-colors: none;
	-moz-transform: rotate(-120deg);
	-webkit-border-bottom-colors: none;
	-webkit-border-left-colors: none;
	-webkit-border-right-colors: none;
	-webkit-border-top-colors: none;
	-webkit-transform: rotate(-120deg);
	-o-border-bottom-colors: none;
	-o-border-left-colors: none;
	-o-border-right-colors: none;
	-o-border-top-colors: none;
	-o-transform: rotate(-120deg);
	-ms-transform: rotate(-120deg);
	border-color: transparent red;
	border-image: none;
	border-style: solid;
	border-width: 0px 30px 100px 0;
	bottom: 115px;
	content: "";
	display: block;
	right: 75px;
	position: absolute;
	width: 0;
	z-index: 3;
}

And in the same way you can create speech bubbles, placing the triangle (see example) wherever you want, just by chaning the rotation degrees and the top/bottom and left/right position via CSS.

Categories

Archive