It relies on the width of the content plus the margin-'s to determine the radius, then extends the height to match using the padding-'s. The margin-'s would need to be adjusted based on the font-size.
Uses pseudo-elements to force the height. Need the zero width space for vertical alignment. Moved the line-height:0px from the outer to the pseudo so that it is at least visible when degrading for IE8.
My solution here - this easily allows for different sizes and colors and ties into a CMS for editorial control. For IE degrading to squares.
HTML:
CSS:
It's not too difficult to see how to do this. The bigger question is whether it is possible to make the dimensions of the circle scale to content.
Currently I don't think it is possible. Anyone?
Something like what I've done here could work (for numbers 0 to 99):
CSS:
HTML:
Heres my way of doing it, using square method. upside is it works with different values, but you need 2 spans.
You can use the border-radius for this:
Play with the border radius and the padding values until you are satisfied with the result.
But this won't work in all browsers. I guess IE still does not support rounded corners.
For circle sizes varying based on the content this should work:
http://jsfiddle.net/nzsnw55s/
It relies on the width of the content plus the
margin-
's to determine the radius, then extends the height to match using thepadding-
's. Themargin-
's would need to be adjusted based on the font-size.Update to remove inner element:
Uses pseudo-elements to force the height. Need the zero width space for vertical alignment. Moved the
line-height:0px
from the outer to the pseudo so that it is at least visible when degrading for IE8.Improving the first answer just get rid of the padding and add
line-height
andvertical-align
: