How to use CSS to surround a number with a circle?

css circle with text
set text on a circle css
circle-icon css
css white circle
css filled circle
css circle div
circle background css
blue circle css

I would like to surround a number in a circle like in this image:

Is this possible and how is it achieved?


Here's a demo on JSFiddle and a snippet:

.numberCircle {
    border-radius: 50%;
    width: 36px;
    height: 36px;
    padding: 8px;

    background: #fff;
    border: 2px solid #666;
    color: #666;
    text-align: center;

    font: 32px Arial, sans-serif;
}
<div class="numberCircle">30</div>

Circled number with pure CSS, If you want a bigger circle, change either font-size to enlarge everything by the same amount (both text and circle) or width, line-height and the  If you are mixing 1 digit numbers and 4 digit numbers, it won’t work. If the ratio between the font size and the circle size isn’t perfect, you’ll either end up with an oval or a small number vertically aligned at the top of a large circle. This should work fine for any amount of text and any size circle.


The problem with most of the other answers here is you need to tweak the size of the outer container so that it is the perfect size based on the font size and number of characters to be displayed. If you are mixing 1 digit numbers and 4 digit numbers, it won't work. If the ratio between the font size and the circle size isn't perfect, you'll either end up with an oval or a small number vertically aligned at the top of a large circle. This should work fine for any amount of text and any size circle. Just set the width and line-height to the same value:

.numberCircle {
    width: 120px;
    line-height: 120px;
    border-radius: 50%;
    text-align: center;
    font-size: 32px;
    border: 2px solid #666;
}
<div class="numberCircle">1</div>
<div class="numberCircle">100</div>
<div class="numberCircle">10000</div>
<div class="numberCircle">1000000</div>

Colored Numbered Circles Using Pure CSS & HTML, To increase the size, you can wrap the HTML using the WordPress Heading tags or simply add a font-size to each CSS rule. colored number circle. HTML; CSS. Most of us immediately think that the simplest solution is to use CSS to style a number with the number centred within a circle. Although CSS allows for many styling options, for numbers from 1 to 20, the quickest and easiest is to use Unicode circled numbers. Unicode HTML entities (HEX or decimal) are so simple to insert into WordPress, Joomla, Shopify, Weebly or most other HTML generating software.


If it's 20 and lower, you can just use the unicode characters ① ② ... ⑳

http://www.alanwood.net/unicode/enclosed_alphanumerics.html

CSS Number in a Circle - JSFiddle, Creating a number within a circle using CSS */. CSS Tidy. 15. 1 .circle {. 2. border​: 0.1em solid grey;. 3. border-radius: 100%;. 4. height: 2em;. 5. width: 2em;. 6. If you want a bigger circle, change either font-size to enlarge everything by the same amount (both text and circle) or width, line-height and the border-radius' to only affect the circle (border-radius = half of the width and line-height values).


For circle sizes varying based on the content this should work:

http://jsfiddle.net/nzsnw55s/

<span class="numberCircle"><span>30</span></span>
<span class="numberCircle"><span>1</span></span>
<span class="numberCircle"><span>5435</span></span>
<span class="numberCircle"><span>2</span></span>
<span class="numberCircle"><span>100</span></span>

.numberCircle {
  display:inline-block;
  line-height:0px;

  border-radius:50%;
  border:2px solid;

  font-size:32px;
}

.numberCircle span {
  display:inline-block;

  padding-top:50%;
  padding-bottom:50%;

  margin-left:8px;
  margin-right:8px;
}

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.

Update to remove inner element:

<span class="numberCircle">30</span>
<span class="numberCircle">1</span>
<span class="numberCircle">5435</span>
<span class="numberCircle">2</span>
<span class="numberCircle">100</span>

<style type="text/css">
.numberCircle {
    display:inline-block;

    border-radius:50%;
    border:2px solid;

    font-size:32px;
}

.numberCircle:before,
.numberCircle:after {
    content:'\200B';
    display:inline-block;
    line-height:0px;

    padding-top:50%;
    padding-bottom:50%;
}

.numberCircle:before {
    padding-left:8px;
}
.numberCircle:after {
    padding-right:8px;
}
</style>

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.

Easily create a number in a circle in HTML, Learn how to create a number with a circle around it without using CSS. All you need do to use Unicode circled numbers is to search the  To increase the size, you can wrap the HTML using the WordPress Heading tags or simply add a font-size to each CSS rule. See the Pen oKrFg by Brad Dalton (@braddalton) on CodePen. Installation. Simply copy all the CSS code and paste it at the end of your child themes style.css file.


the easiest way is using bootstrap and badge class

 <span class="badge">1</span>

Placing Items on a Circle, It can be quite challenging to place items on a circle with CSS. she managed to do it in a Stack Overflow answer, using chained CSS transforms. @param {​Integer} $item-count - Number of items on the circle /// @param  Making circles with CSS is very simple. Just make the radius half of the width and height of the element to make a perfect circle, or simply use: border-radius:50% Responsive Circle With or Without Text Inside. Narrow your browser window horizontally to test the circle’s responsiveness.


Responsive circle with centered text, You should add line-height:0; in your PEN. without it , If you are on a really small screen then your “ICON” will no longer available in center. TRY  Before adding float: right, when this selection would happen, it would only surround a narrow area around the number creating an oval. After adding float: right, the clicked number is surrounded with a circle with plenty of space between the edge and the number, as it should be. However, the float is now affecting the grid and has shifted it to the right of the page.


How To Create Circles / Round Dots, Step 2) Add CSS: To create a circle, use the border-radius property and set the value to 50%. Then combine the height and width properties with a matching  Step 2) Add CSS: To create a circle, use the border-radius property and set the value to 50%. Then combine the height and width properties with a matching value:


shape-outside, The shape-outside CSS property defines a shape—which may be type, that type is ellipse() or circle() , and none of the radii use the closest-side or both polygons have the same number of vertices, and use the same  The cx and cy attributes define the x and y coordinates of the center of the circle. If cx and cy are omitted, the circle's center is set to (0,0) The r attribute defines the radius of the circle. Previous Next