Frontend Interview Question: How to use CSS to surround a circle around a number

Marika Lam
Aug 1, 2024

I recently came across an interview question where it involves creating a circle around a number. And the number needs to be in the center/middle of the circle. Without downloading a png file to have the number overlap, below is a solution where it requires a change to the CSS of the div.

This is what the end product should look like.

CSS file

.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;
}

Javascript file

<div class="numberCircle">30</div>

--

--