Validator bubbles with CSS arrows

by Frédéric Hamidi

HTML

<div class="bubble left">
    <div class="arrow">
        <div class="arrow-inner">
        </div>
    </div>
    <div class="content">
        <b>Error message goes here.</b>
        <br />
        Specific instructions go there, possibly on multiple lines.
    </div>
</div>
<br />
<input type="button" value="Flip" />

CSS

body {
    font-family: Verdana, Arial, sans-serif;
    font-size: 12px;
}

.bubble {
    border: none;
    margin: 0px;
    padding: 0px;
    position: relative;
    width: 200px;
}

.left {
    padding-left: 17px;
}

.right {
    padding-right: 17px;
}

.arrow {
    position: absolute;
    top: 6px;
}

.arrow-inner {
    position: absolute;
    top: -16px;
}

.left .arrow {
    border-bottom: none;
    border-left: 18px solid transparent;
    border-right: none;
    border-top: 18px solid black;
    height: 0px;
    left: -1px;
    width: 0px;
}

.left .arrow-inner {
    border-bottom: none;
    border-left: 16px solid transparent;
    border-right: none;
    border-top: 16px solid lemonchiffon;
    height: 0px;
    left: -13px;
    width: 0px;
}

.right .arrow {
    border-bottom: none;
    border-left: none;
    border-right: 18px solid transparent;
    border-top: 18px solid black;
    height: 0px;
    right: -1px;
    width: 0px;
}

.right .arrow-inner {
    border-bottom: none;
    border-left: none;
    border-right: 16px solid transparent;
    border-top: 16px solid lemonchiffon;
    height: 0px;
    right: -13px;
    width: 0px;
}

.content {
    background-color: lemonchiffon;
    border: 2px solid black;
    font-family: Verdana;
    font-size: 10px;
    padding: 5px;
}

.content b:first-child {
    display: inline-block;
    font-family: Tahoma;
    font-size: 11px;
    padding-bottom: 2px;
}

JavaScript

$(document).ready(function() {
    $("input").click(function() {
        $(".bubble").toggleClass("left right");
    });
});