Stackoverflow - Vertically and horizontally centering text in circle in CSS (like iphone notification badge)
http://stackoverflow.com/q/4801181/918414
by panique
HTML
<div class="badge">1</div>
<div class="badge">2</div>
<div class="badge">3</div>
<div class="badge">44</div>
<div class="badge">55</div>
<div class="badge">666</div>
<div class="badge">777</div>
<div class="badge">8888</div>
<div class="badge">9999</div>
<script>
/* by: thinkingstiff.com
license: http://creativecommons.org/licenses/by-nc-sa/3.0/us/ */
var headerUri = 'http://stackoverflow.com/q/4801181/918414',
headerCaption = 'Vertically and horizontally centering text in circle in CSS (like iphone notification badge)';
document.body.insertAdjacentHTML(
'afterBegin',
'<a href="' + headerUri + '" '
+ 'target="_top" '
+...
CSS
.badge {
background: radial-gradient( 5px -9px, circle, white 8%, red 26px );
background: -moz-radial-gradient( 5px -9px, circle, white 8%, red 26px );
background: -ms-radial-gradient( 5px -9px, circle, white 8%, red 26px );
background: -o-radial-gradient( 5px -9px, circle, white 8%, red 26px );
background: -webkit-radial-gradient( 5px -9px, circle, white 8%, red 26px );
background-color: red;
border: 2px solid white;
border-radius: 12px; /* one half of ( (border * 2) + height + padding ) */
box-shadow: 1px 1px 1px black;
color: white;
font: bold 15px/13px Helvetica, Verdana, Tahoma;
height: 16px;
padding: 4px 3px 0 3px;
text-align: center;
min-width: 14px;
}
/* only needed for this sample */
.badge {
float: left;
left: 25px;
margin: 6px;
position: relative;
top: 25px;
}