I have transformed my navigation menu into a series of CSS circles with text inside. The issue I am facing is that the text spills out unevenly based on the amount of content in each circle. To address this, I used a JavaScript solution to center-align the text horizontally within the circles. However, I now encounter a new problem where the baselines of the circles are not consistent due to varying text lengths. Is there a straightforward CSS fix for this, or will I need to calculate and adjust the heights of each list item using JavaScript?
.html
<ul class="list-inline nav-horizontal">
<li role="presentation" class="active">
<a href="#1" data-toggle="tab" class="stylish">#1</a>
</li>
<li role="presentation">
<a href="#2" data-toggle="tab" class="stylish">#2</a>
</li>
<li role="presentation">
<a href="#3" data-toggle="tab" class="stylish">#3</a>
</li>
<li role="presentation">
<a href="#4" data-toggle="tab" class="stylish">#4</a>
</li>
<li role="presentation">
<a href="#5" data-toggle="tab" class="stylish">#5</a>
</li>
</ul>
.css
.list-inline {
display: inline-block;
padding: 6px;
}
.stylish {
display: block;
width: 140px;
height: 140px;
border-radius: 50%;
border: 8px solid #ED1B24;
font-size: 20px;
color: #BBAE92;
text-align: center;
text-decoration: none;
background: none;
line-height: 1.1em;
}
.stylish:hover, li.active .stylish {
color: #fff;
text-decoration: none;
background: #ED1B24;
}
.js
$("a.stylish").contents().wrap("<span>");
$("a.stylish span").css({
position : "relative",
"top" : function() {
return ($(this).parent().height() - $(this).height()) / 2
}
});