How to create a basic tooltip using CSS3
One of the projects I'm working on requires basic menu items that are styled like tooltips. Below is a very simple example of how to achieve that style by creating a CSS triangle and using the :after
selector.
We'll just call the element .tooltip
<div class="tooltip">item</div>
.tooltip {
height: 50px;
width: 50px;
max-width: 50px;
display: inline-block;
padding: 5px;
position: absolute;
color: rgba(255, 255, 255, 0.9);
line-height: 50px;
text-align: center;
background: #3C8BBD;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}
.tooltip:after {
content: "";
border-width: 8px 6px 0 6px;
border-style: solid;
border-color: #3C8BBD rgba(0, 0, 0, 0);
display: block;
position: absolute;
bottom: -8px;
left: 50%;
margin-left: -6px;
z-index: 220;
width: 0;
}