I'm trying to create a circle border around a number like so:
But so far all my attempts have resulted in an oval:
Codepen to see it live SCSS code so far
$browser-context: 16;
@function em($pixels, $context: $browser-context) {
@return #{$pixels/$context}em;
}
body {
line-height: 1.6;
display: flex;
flex-direction: column;
min-height: 100vh;
font-family: 'PT Sans', sans-serif;
background: #e5dde1;
}
ul {
margin: 0;
padding: 0;
list-style: none;
}
.header-nav {
background-color: #ff4c61;
color: white;
font-family: 'Oswald', sans-serif;
}
.category-nav ul {
background-color: #212d5b;
color: #ff4c61;
display: flex;
justify-content: space-evenly;
}
.category-nav a {
font-size: em(34);
text-decoration: none;
}
.category-nav .circled {
border-radius: 50%;
width: em(12);
height: em(12);
padding: em(4);
border: em(1) solid #ff4c61;
}
HTML:
<header class="header-nav">
<h1> APP</h1>
</header>
<nav class="category-nav">
<ul>
<li><a href="#">A</a></li>
<li><a href="#">B</a></li>
<li><a href="#">C <span class="circled">3</span></a></li>
</ul>
</nav>
I been experimenting different solutions so far and I think the problem comes mostly from the fact that container of the number is an inline element (span). Whenever I switch the class .circled
to a div instead or set the display to block, I get a perfect circle but then the number is pushed out and it breaks the flex layout. I wonder if there's any way to get the circle to work with a span?